Skip to Content
What's New in SQL Server 2012
book

What's New in SQL Server 2012

by Rachel Horder
October 2012
Intermediate to advanced
238 pages
5h 17m
English
Packt Publishing
Content preview from What's New in SQL Server 2012

Conversion functions

SQL Server 2012 introduces some useful conversion functions that will help you avoid errors when dealing with different data types. We will use easy-to-understand examples so you can see how beneficial they are.

TRY_PARSE

TRY_PARSE doesn't look too useful on surface, but as we will soon see it has a vey useful specialist niche.

The basic syntax of TRY_PARSE is as follows:

SELECT TRY_PARSE (string AS datatype)

Each of the following will return a NULL, as the value passed in the string does not convert to a value of the data type specified as the second parameter:

SELECT TRY_PARSE ('SQL Server 2012' AS datetime) AS MyDateTime SELECT TRY_PARSE ('SQL Server 2012' AS decimal) AS MyDecimal SELECT TRY_PARSE ('ABC' AS float) AS MyFloat ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Microsoft® SQL Server 2012 Unleashed

Microsoft® SQL Server 2012 Unleashed

Ray Rankins, Paul T. Bertucci, Chris Gallelli, Alex T. Silverstein
Pro SQL Server 2012 Practices

Pro SQL Server 2012 Practices

Bradley Ball, TJay Belt, Glenn Berry, Jes Borland, Carlos Bossy, Louis Davidson, Ben DeBow, Grant Fritchey, Jonathan Gardner, Jesper Johansen, Jeremy Lowell, Wendy Pastrick, Kellyn Pot'vin, Mladen Prajdić, Herve Roggero, Chris Shaw, Gail Shaw, Jason Strate
Microsoft® SQL Server 2005 Unleashed

Microsoft® SQL Server 2005 Unleashed

Ray Rankins, Paul Bertucci, Chris Gallelli, Alex T. Silverstein, Tudor Trufinescu, John Kane

Publisher Resources

ISBN: 9781849687348Other