Search This Blog & Web

Wednesday, August 19, 2009

Create and Use Templates -- SSMS Enhancements 2008

We can save our custome code and execute it several time for testing like if you want to "returning all column information" and you have no time to search for query every time you need then their is an other way to remember and use that.Another example is if you want to test you procedure to execute several time with different parameters then you can use SSMS template for that.

To get that we have to follow these steps.

1. In the Object Explorer go to view -- > Template Explorer
2. There are several templates to use in.
3. Right click on Sql Server Templates and Add New Folder
4. Right clieck on Folder and Add new Template
5. Set the Name of the Template and then click edit for write you sql
6. Write your query there like
        Select * from information_schema.tables where table_name = 'abc'
7.  Run this query and save the template.
8. Open it again in edit mode and this time apply following changes.
         Select * from information_schema.tables where table_name = ''
9.  Save and close the Template window
10. Now open the Template agin by duble click on the file.
11. go to Query -- > Specify Values for Template Parameter
12. as parameter displays their
13.  Enter value of parameter and see how Template work for several conditions.

Here are some Sample Pictures.
Picture1 : Template explorer with New Template file and folder
 
Picture 2 : Passing parameter values

 
Picture 3: After providing values query looks like
 
Post a Comment