Translate

Monday, October 31, 2011

TRY_CONVERT

I am sure you would have used CONVERT function many times.

image

If you see the above data set, last date value is an invalid date. If you are integrating with legacy systems, you will these types of records.

They you might need to convert these into a date time value. Naturally, you will use, CONVERT function.

image

But it will fail.

image

In Denali or SQL Server 2012 (as per CTP3) you have new function called TRY_CONVERT.

image

With this new function, you won’t get the error as well as you will be able to find out the errors as well.

Following query will return all the rows where you have an invalid date value.

image

You can use this for other data types as well.

Download the code from here

Sunday, October 16, 2011

SQL Server 2008 SP3 is now available!

Microsoft SQL Server Sustained Engineering group is pleased to announce the release of SQL Server 2008 Service Pack 3 (SP3). Both the Service Pack and Feature Pack updates are available for download on the Microsoft Download Center. As part of our continued commitment to software excellence for our customers, this upgrade is free and doesn’t require an additional service contract.

Download it from here