O'Reilly logo

Microsoft® SQL Server 2012 Unleashed by Alex T. Silverstein, Chris Gallelli, Paul T. Bertucci, Ray Rankins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The TRY_CONVERT Function

The TRY_CONVERT function available in SQL Server 2012 is similar to the TRY_PARSE function in that if the conversion is successful, it returns the value as the specified data type. Otherwise, it returns a NULL value. However, if you request a conversion that is explicitly not permitted, TRY_CONVERT fails with an error.

Like CONVERT, TRY_CONVERT can handle converting to data types other than integer or date and time values.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required