Exploring SQL Server 2012: Code Snippets

One of the new features available in SQL Server 2012 is the Code Snippet Manager.  Previously this was available through third-party tools and add-ins.  The Code Snippets Manager is available through the Tools menu, along with some other nice built-in tools as well for this release.

Here you can see that there are many nice built-in code snippets included off the shelf.  The tool allows you to insert the XML formatted snippets (a la Visual Studio).   Click here for information on how to create your own snippets from the MSDN.  Personally I think the interface should have the functionality to just insert snippets of code like other add-in tools, however it is better than what we had previously off-the-shelf.

Figure 1 – Code Snippet Manager


This looks great but there is no insert button to put these snippets into my code, I tried.  So how do I enter the code into the query editor as I type?  Hold the control button (CTRL) and then press the K and then X to begin the insert, and yes I know this is an awkward key combination (what where they thinking).  See figure 2 and choose a category of snippets.

Figure 2 – Insert Snippet

After choosing a category then choose a snippet (see figure 3).

Figure 3 – Choose a Snippet

After choosing your snippet, it will be inserted into the query editor (see Figure 4).  At this point you can customize the snippet to fit your code and you are done!  Enjoy!

Figure 4 – The Finished Snippet





About SQLGator

Microsoft Data Platform MVP, Florida Gator, Star Wars fanatic and is there anything else...oh yeah PS4! I am a geek and SQL Server Business Intelligence Consultant, there are other technologies greater than these? Not so fast my friend! I also love to travel to new and exotic places.

Posted on November 20, 2012, in Scripting and tagged , . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: