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.
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.
After choosing a category then choose a snippet (see figure 3).
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!