Home » SQL Server Template Explorer

SQL Server Template Explorer

SQL Server Template Explorer




As a SQL Server beginner or professional, sometimes you may forget the syntax or scripts such as add constraints in a table, Create a system version tables, or may be create a stored procedure, trigger or it could be any other easy or may be complex scripts.

In this situation you do google or seek for someone help, if you do google then it gives you the best possible result for your search but that may, or may not match your expectation, or you may have to search multiple times to see the exact result that meets your expectation.

If you usually forgets the scripts and want to avoid to google for it then you can use SQL Server template Explorer, SQL Server Management Studio provides you a build-in templates for  scripts.

Using this template you can also improve your SQL skills in terms of writing a well formed SQL Scripts in proper well defined way.

Lets see how you can use SQL Server template to generate a scripts for you.

Following are the steps –

Go to SSMS header bar, click on View then select Template Explorer.

Once you click on Template Explorer,  a Template Browser opens either on left side of your query editor screen or right side of query editor screen , depends on your SSMS default settings.
In Template browser you can see, there are lots of template that provides you a template of scripts.

Now just dobule click on template that you want to use, and it generate template for your scripts in query editor window.

Lets say you want to see how to add a new column in table, then look for table template in Template browser then expand it , and double click on Add column

Once you double click on Add column, It generates a Add column scripts for you on query editor window.

Now you can see, the add column scripts, now you can take hint from generated add column scripts or if you are able to replace this scripts based on your requirement then fine other wise you can also replace the value in this template with the help of SSMS specify template values for template parameters tool

To replace the template values with your values you need to provide the values for Template Parameters.





Go to SSMS header bar, click on Query then Specify values for template parameters…

 

After that it opens a Specify values for template parameters window that allows you to provide a parameter values for your template, which will be replaced with an existing values on template.

 

Lets provide the parameter values for template.

Once you provide the value for parameters, click on OK button.

 

Now you can see, all the given values for parametes are replaced with an existing values in template on query editor window.

As you were looking for add new column scripts so you can use alter table command only else scripts you can ignore, which were there just for your better understanding.

 

It is very helpful especially for beginner, who want improve their skills, can learn how to write well defined scripts with proper structure.




Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.