New toys in SQL Server 2012

, 2014-09-01 (first published: )

The SQL Server 2012 Management Studio now tries to look like the Visual Studio. It is including more and more features similar to attract VS developers. In this article we are going to look two new enhancements: the Insert snippet menu option and the surround with option.

Insert snippet

The insert snippet let us create code easily. For example we can create tables and views in few seconds. Let’s take a look at it.

Getting started

To start the Insert Snippet, right click in the SQL Server Management Studio Script pane and select Insert Snippet or press Ctrl+k,Ctrl+x

You can easily generate code to create functions, indexes, logins, roles, schemas, stored procedures, synonyms, tables and triggers. In our example we are going to choose table:

Finally, select the option Create Table:

The code created is the following:

CREATE TABLE dbo.Sample_Table
    column_1 int NOT NULL,
    column_2 int NULL

It is useful to create simple examples for testing purposes or to generate code automatically to start with real code for real scenarios.

I reviewed the stored procedure and it generates code for 3 scenarios: These scenarios are the basic procedure, a procedure with cursors and a procedure with output parameters. These simple enhancements will help a lot to Developers and DBAs that use the SQL Server.

 The code generated is pretty simple and useful:

CREATE PROCEDURE dbo.Sample_Procedure
    @param1 int = 0,
    @param2 int 
    SELECT @param1,@param2

Surround with option

Another new option is the Surround with. To activate this option, right click in the SQL Server Management Studio Script pane and select Surround with or press Ctrl+k,Ctrl+s

The surround with let us generate BEGIN END clauses, WHILE Loops and IF conditions easily:




If condition

IF( Condition )



While loop

WHILE( Condition )



SQL Server is including new features to be easier to use and to create code. SSDT includes even more power, but this is a topic that we will talk about deeply in a future article.


Insert Transact-SQL Snippets

Insert Surround-with Transact-SQL snippets


2.5 (113)




2.5 (113)

Related content