WiseOwl Training - Established 1992 Wise Owl Training

Established May 1992
30 years in business
Wise Owl Training
30 years in business
See 527 reviews for our classroom and online training
New in SQL 2012 - code snippets and surrounding code
Part two of a three-part series of blogs

In a previous blog on new features of SQL 2012, I missed out the ability to insert code snippets, and also to embed or surround code in an IF, BEGIN or WHILE block. This blog rectifies this!

  1. New Features for Writing SQL in SSMS 2012
  2. Code Snippets in SQL Server 2012 (this blog)
  3. Surrounding Code in SQL Server 2012

Posted by Andy Brown on 15 May 2012

You need a minimum screen resolution of about 700 pixels width to see our blogs. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.

Code Snippets in SQL Server 2012

VB and C# programmers have had it for years, but SQL programmers can now have it too.  It is code snippets.

How Code Snippets Work in SSMS 2012

Here's how it works.  You want to create a stored procedure, but can't remember the exact syntax.  So you insert a snippet:

Inserting a snippet

Choose the menu option to insert a snippet

Next, choose what you want to insert (there's pretty much every SQL construct in the list):

Choose stored procedure

You can choose what sort of SQL construct you want to insert.


Finally, choose how you want to insert (in this case) a stored procedure:

Create procedure basic template

Here we're choosing to put in a simple stored procedure.

Here's what you get for this example:

-- I'm in a snippety sort of mood ...

CREATE PROCEDURE dbo.Sample_Procedure

@param1 int = 0,

@param2 int


SELECT @param1,@param2


You can now modify this to suit your needs.

Note that you can even create your own custom snippets in SQL.

This blog has 0 threads Add post