You are here:Home » t-sql » Custom Code Snippet - SQL Server Denali

Custom Code Snippet - SQL Server Denali

In a previous post of code snippet, I have written about how code snippet is useful and how to use in query editor. It is a good enhancement of query editor. Now I am going to write for the code snippet, but not for the inbuilt code snippet, going for custom code snippet. We can also create custom code snippet. Here I have created one custom snippet for Sequence.

How we can?
There we need a snippet file and required to import or add. I have created sequence snippet from one application which you can download from here. The format for creating custom snippet files as like following.

Or we can also generate this custom snippet file from following utility.

After applying the code for snippet when you click on generate script, it will save the snippet file. Finally, we need to import this created snippet file in SQL Server. Just go to Tools --> Code Snippets Manager or Ctrl + K, Ctrl + B.

We have done with a custom snippet and imported or added successfully. Now how can we use this custom code snippet of sequence in query editor? That is here.

Press Ctrl + K, Ctrl + X or go on Edit --> Intellisense --> Insert Snippets.

After click on Sequence following tsql will be generated.

CREATE SEQUENCE NewGlobalSequence    
   MAXVALUE 1000  

I hope you liked this post. Have you tried with the custom code snippet?