New T-SQL functions in SQL Server 2012:
--PARSE()
--Parse Currency Symbol
SELECT PARSE('$100' AS MONEY USING 'EN-US') AS Currency
--Result = 100.00
--Parse DATETIME
SELECT PARSE('Monday, 13 December 2010' AS datetime2 USING 'en-US') AS US_Date
--Result = 2010-12-13 00:00:00.0000000
--CONCAT()
SELECT CONCAT('Firstname',' ','Surname') AS MyName
--Result = Firstname Surname
--CHOOSE()
DECLARE @Letter INT = 4
SELECT CHOOSE(@Letter, 'A','B','C','D', 'E','F')
--Result = D
--IIF()
DECLARE @Letter INT = 5
SELECT IIF(@Letter % 2 > 0,'ODD','EVEN')
--Result = ODD
--Get Date for the provided yy,MM,dd
SELECT DATEFROMPARTS(1999,2,3)
--GET LastDate of Month
SELECT EOMONTH(GETDATE(),0)
--PARSE()
--Parse Currency Symbol
SELECT PARSE('$100' AS MONEY USING 'EN-US') AS Currency
--Result = 100.00
--Parse DATETIME
SELECT PARSE('Monday, 13 December 2010' AS datetime2 USING 'en-US') AS US_Date
--Result = 2010-12-13 00:00:00.0000000
--CONCAT()
SELECT CONCAT('Firstname',' ','Surname') AS MyName
--Result = Firstname Surname
--CHOOSE()
DECLARE @Letter INT = 4
SELECT CHOOSE(@Letter, 'A','B','C','D', 'E','F')
--Result = D
--IIF()
DECLARE @Letter INT = 5
SELECT IIF(@Letter % 2 > 0,'ODD','EVEN')
--Result = ODD
--Get Date for the provided yy,MM,dd
SELECT DATEFROMPARTS(1999,2,3)
--GET LastDate of Month
SELECT EOMONTH(GETDATE(),0)
No comments:
Post a Comment