"No one is harder on a talented person than the person themselves" - Linda Wilkinson ; "Trust your guts and don't follow the herd" ; "Validate direction not destination" ;

March 16, 2012

TSQL Enhancements in SQL 2012 - Part I

[Next Post in Series - TSQL Enhancements in SQL 2012 - Part II]

I had taken Session on SQL 2008 TSQL Enhancements, SQL 2008 R2 TSQL Enhancements in my earlier roles. This post is to cover TSQL Enhancements in SQL 2012. Online SQL Server Virtual Labs is available in Link. You should give it a try. I have tried couple of exercises for Enhancements in TSQL for SQL Server 2012
  • Throw Feature Support in Try-Catch
  • IIF - Simplify IF-ELSE Logic
  • CHOOSE - Select a value from a list based on index of value
  • CONCAT - String Concatenate Feature
Throw Keyword Support

Feature addition is Throw keyword is supported to throw exception. This is useful for debugging, You can set throw option to debug. For logging you can use catch option and log errors for production database

Normal Try-Catch Scenario


With Throw Keyword
 
Concat
  • Concatenate Column Values, Useful for Results Reporting Purpose


IIF and CHOOSE
  • IIF simplifies IF else condition specifying both in a single line
Example - Maximum of 3 numbers

CHOOSE
  • Return based on index value specified
Next Post we would cover
  • TRY_CONVERT
  • Format
Happy Learning!!!!

No comments: