SQL Server 2012 came up with many new features and enhancements. Insert Snippet is one of the new features introduced in it. This feature reduces the development time and increases productivity. How ? It basically generates the code snippet for the most frequently used objects in SQL Server instantly (with few clicks or key strokes). But it is not limited to the frequently used objects, custom code snippet template can also be added in it and can generate it at any point of time, to make life easier. How to create custom code snippet will be demonstrated in my up coming article.
Given below are the object’s code snippet available in SQL Server as a standard template :
- Stored Procedure
- User Defined Data Type
- User Defined Table Type
- User Defined Type
Let me insert a Create Table code snippet step by step using Insert snippet .
Open a new query window in the Database Engine and place the cursor where the code snippet has to be inserted.
In this step, launch snippet picker to insert Snippet. It can be done using three different methods. Given below are the details of these methods.
Press CTRL+K, CTRL+X to launch snippet picker.
Go to the Edit Menu then point to IntelliSense and then select Insert Snippet to launch snippet picker as shown in the picture below .
Right click and select Insert Snippet to launch snippet picker as shown in the picture below.
Once the snippet picker is launched, select table from the list as shown in the picture below.
After selecting the Table press TAB or Enter key to proceed as shown in the picture below.
After selecting the Create Table script as show in the above picture then again press TAB or Enter key to generate the code snippet as shown below.
Notice that the create table code snippet in the above image has been generated. Now just change the highlighted area to create desired customized table. Additional columns as well can be added.
Insert Snippet is a very nice feature introduced in SQL Server 2012. Time saving tool. The example discussed above took less than 10 seconds to create it. Also it is not limited to create table code snippet alone, any object code snippet can be created in less than 10 seconds.
Will post how to create the customized code snippet in my upcoming post.