In SQL Server 2012 and 2014 Microsoft introduced many new features and enhancements. In fact there were 14 new in-built functions introduced in SQL Server 2012. However I noticed that for some reason I don’t see many people using them. In my company we upgraded all our servers to 2014 from 2008R2 almost a year back but I see none of the developers using them or even aware. Also in last 6 months I interviewed many people and one of the question I asked to candidates that are you aware of any new features of SQL Server 2012/14? While most of the people talked about the changes in SSIS, project deployment etc but very few knew about the 14 new in-built functions introduced in SQL Server 2012.
So I thought of writing about these new in-built functions. In this post I’m not going to write the details of these function. This is just going to be a reminder that now we have 14 more in-built functions that can help us in writing SQL code.
Conversion functions
1. PARSE (Transact-SQL) : PARSE function converts the string expression to the requested data type. And if it fails to translate then raises an exception.
2. TRY_CONVERT (Transact-SQL): Returns a value cast to the specified data type if the cast succeeds; otherwise, returns null.
3. TRY_PARSE (Transact-SQL): Returns the result of an expression, translated to the requested data type, or null if the cast fails
You might wonder what is the difference between PARSE and CONVERT or may be PARSE and TRY_PARSE; I’ll try to explain that in my next few posts.
Date and time functions
4. DATEFROMPARTS (Transact-SQL): Returns a date value for the specified year, month, and day.
5. DATETIME2FROMPARTS (Transact-SQL): Returns a datetime2 value for the specified date and time and with the specified precision.
6. DATETIMEFROMPARTS (Transact-SQL): Returns a datetime value for the specified date and time.
7. DATETIMEOFFSETFROMPARTS (Transact-SQL): Returns a datetimeoffset value for the specified date and time and with the specified offsets and precision.
8. EOMONTH (Transact-SQL): Returns the last day of the month that contains the specified date, with an optional offset.
9. SMALLDATETIMEFROMPARTS (Transact-SQL): Returns a smalldatetime value for the specified date and time.
10. TIMEFROMPARTS (Transact-SQL): Returns a time value for the specified time and with the specified precision.
Logical functions
11. CHOOSE (Transact-SQL): Returns the item at the specified index from a list of values.
12. IIF (Transact-SQL): Returns one of two values, depending on whether the Boolean expression evaluates to true or false.
String functions
13. CONCAT (Transact-SQL): Returns a string that is the result of concatenating two or more string values.
14. FORMAT (Transact-SQL): Returns a value formatted with the specified format and optional culture.
To know more about each of these new functions you can click on the names of the functions. In my future posts I’ll try explain each of these functions in details with some examples and situation where they can be useful.
To know more about the new features introduced in the SQL Server please follow below links:
What's New in SQL Server 2012
What's New in SQL Server 2014
A Sneak Peek into the Future: What's New in SQL Server 2016