Using Snippets

Leave a comment

October 17, 2016 by Kenneth Fisher

A while ago I talked about Templates. This is an easy way to get a, well, template of a piece of code. But a much faster way to get a simple template is to use a snippet. With a simple key command (ctrl-K, ctrl-X) you can open up the snippet picker and quickly navigate to the snippet you need.

Note: You can also open the snippet picker by right clicking and selecting Insert Snippet… or from the menu Edit -> Intellisense -> Insert Snippet…

Further note: snippet picker sounds really odd but it was the name in BOL so we’ll go with it.

Demo time! First things first I want to add a new snippet. I opened the Snippet Manager.

snippits1_add

and selected a snippet I wanted to model on. When you look at the snippet through the manager you can see the file location. I opened it up in notepad (it’s just a simple XML file), modified it, then saved it alongside the original.

create-multi-table-view

I should point out that the file was located in a protected location so I had to open notepad as an administrator. Once I saved the file my new snippet was ready to go.

snippits2_add

Well, actually I had to create another new snippet before it would show up in the snippet picker (or possibly I could have re-started SSMS).

Now I was ready to start creating code!

snippet

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.

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 3,755 other subscribers

Follow me on Twitter

ToadWorld Pro of the Month November 2013
%d bloggers like this: