SQL Server 2012 – New T-SQL Function

–Parse String (amount with currency) to money
SELECT PARSE(‘€791,33’ AS money USING ‘de-DE’)

— Returns a value cast to the specified data type if the cast succeeds; otherwise, returns null.
SELECT  TRY_CONVERT(integer, ‘hello’) 
SELECT TRY_PARSE(‘Jabberwokkie’ AS datetime2 USING ‘en-US’) AS Result

— Return Orange, choose 2nd item from the list
SELECT CHOOSE ( 2, ‘Apple’, ‘Orange’, ‘Lemon’ ) AS Result;

— Return Biro, similar to excel function
SELECT IIF ( 7 > 9, ‘Amar’, ‘Biro’ ) AS Result;

— Return “Jack Monde 123”, Combine 2 or more object, accept string, null, number, etc
SELECT CONCAT ( ‘Jack  ‘, ‘Monde ‘, NULL, 123 )

— Date Formatting Function
DECLARE @d DATETIME = ’10/16/2005′;

SELECT FORMAT ( @d, ‘d’, ‘de-de’ ) AS ‘German’
SELECT FORMAT ( @d, ‘d’, ‘en-gb’ ) AS ‘Great Britain’
SELECT FORMAT ( @d, ‘d’, ‘zh-cn’ ) AS ‘Simplified Chinese’

— Return:
image

— New Dynamic Management Views & Functions

SELECT * FROM  sys.dm_os_volume_stats (1, 1)

SELECT * FROM  sys.dm_server_services

SELECT * FROM  sys.dm_server_registry 

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 )

Google+ photo

You are commenting using your Google+ 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 )

w

Connecting to %s