The SQL Server 2012 Management Studio now looks like Visual Studio. It now includes more features to attract VS developers.
In this article we will have a look at two new enhancements: the Insert Snippet menu option and the Surround Menu with options.
Using the code
The Insert Snippet lets us create the basic structure of a Transact-SQL statement or block.
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 T-SQL statements to create Functions, Indexes, Logins, Roles, Schemas, Stored Procedures, Synonyms, Tables, and Triggers.
Let’s take an example for creating a table.
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 for creating simple examples for testing purposes.
I reviewed the Stored Procedure and it generates code for three scenarios: these scenarios are basic Stored Procedures, Stored Procedures
with Cursors and Stored Procedures with output parameters.
The code generated is pretty simple and useful:
CREATE PROCEDURE dbo.Sample_Procedure
@param1 int = 0,
SELECT @param1, @param2
Surround with option
Another new option is Surround with.
The surround will let us generate BEGIN END clauses, WHILE Loops, and IF conditions easily.
To activate this option, right click in the SQL Server Management Studio Script Pane and select Surround with or press Ctrl + K / Ctrl + S