In my second quick tip, I wrote about SQL 2012 IntelliSense Code Snippets in the intelliSense menu. In case you didn’t notice in the drop down for the Code Snippets, there was another option for ‘Surround with…’ just below it. What is this you might ask? Well, it is exactly what it sounds like. This option will allow you to create code that would sound a statement, like the typical Begin/End or While statements.
You would create these the same way you would the Code Snippets. When you are in SSMS (SQL Server management Studio) and open a New Query window, you can simply right-click in that window and click on Surround With… (You can also type Crtl+K, Ctrl+S). The third way is to click Edit on the main menu, chose IntelliSense > Surround With…
Once you click Surround With… it will display 3 different choices. They are the Begin Statement, the If Statement or the While Statement.
Once you click on one, it will write the basic T-SQL code for you. All you have to do is fill in the Condition and what you wish to execute during that condition.
Is this a huge time saver? Not really, but for people new to T-SQL coding, it will set them up with the basic format.