Blog Post

Using Snippets

,

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

Filed under: Microsoft SQL Server, SQLServerPedia Syndication, SSMS, T-SQL Tagged: microsoft sql server, SSMS, T-SQL

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating