SSMS Tips and Tricks 3-12: Using query templates

SSMS Tips and Tricks 3-12: Using query templates

Sometimes you might need help to remember the T-SQL syntax required to create different types of objects. Templates can do this. Because they don’t appear on the screen by default, many people don’t even realize they are there.

From the View menu, you can choose to view Template Explorer:

When Template Explorer opens, you see a list of predefined templates, plus any that you have created yourself. (One advantage of templates is that they are quite easy to create). In this case I’ve expanded the Credential folder, right-clicked the Create Credential template, then clicked Open.

This then opens a new query window with the template for creating a credential inserted.

At this point, it’s tempting to start editing the template manually, but instead click the Specify Values for Template Parameters button on the toolbar.

This finds all the declared parameter values and opens a window where you can enter the values.

By completing the values in this window, you avoid the need to have to put the same value in many places. In this example, the name of the credential is used in several places.

Templates are a great way to work with predefined code layouts. SSMS comes with a large number of T-SQL templates but this feature becomes even more powerful when you create your own. Soon, we’ll discuss how to do that.

2025-07-20