TRY_PARSE()

Today I played around with the TRY_PARSE() function and it does work.
Though it’s an expensive one and as we all know, SQL Server isn’t built for handling strings 🙂

TRY_PARSE SQL Server 2012

Code:

DECLARE @dtSQL VARCHAR(10) = '09-2013-13';
SELECT TRY_CAST(@dtSQL AS datetime2) AS [TRY_CAST Result],
TRY_CONVERT(datetime2, @dtSQL) AS [TRY_CONVERT Result],
TRY_PARSE(@dtSQL AS datetime2) AS [TRY_PARSE Result];
GO

More examples: TRY_CAST(), TRY_CONVERT() and TRY_PARSE() – Compare and Contrast








Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s