How to: Use Templates in SQL Server Management Studio
You can open a template from the File menu, or from Template Explorer. After the template is open, use the Replace Template Parameters dialog box to replace the template parameters with your values.
The following example opens the Create Database template.
To open a template from Template Explorer
On the View menu, click Template Explorer.
In the list of template categories, expand Database, and double-click Create Database to open the template in the appropriate code editor. (You can also drag a template from Template Explorer and drop it onto a Query Editor window, to add the template code.)
In the Connect to Database Engine dialog box, complete the connection information and then click Connect, to open a new query editor window populated with the Create Database template.
To open a template from the File menu
On the File menu, point to New, and then click File.
In the New File dialog box, in the Categories box, expand SQL Server Query, and then click Database.
In the Templates box, click Create Database, and then click Open.
In the Connect to Database Engine dialog box, complete the connection information and then click Connect, to open a new query editor window populated with the Create Database template.
To replace template parameters
On the Query menu, click Specify Values for Template Parameters.
In the Specify Values for Template Parameters dialog box, the Values column contains suggested value for the parameter (Database Name in the example above). Accept the value or replace it with a new value, and then click OK to close the Replace Template Parameters dialog box and modify the script in the query editor.
To create a custom template
In Template Explorer, navigate to the node where you would like to store the new template.
Right-click the node, point to New, and then click Template.
Type the name for your new template and then press ENTER.
Right-click the new template, and then click Edit. In the Connect to Database Engine dialog box, click Connect to open the new template in Query Editor.
Create a script in Query Editor. Insert parameters in your script in the format
<parameter_name, data_type, value>
. The data type and value areas must be present, but can be blank.On the toolbar, click Save to save your new template.
See Also
Other Resources
Creating Custom Templates
Using SQL Server Management Studio Templates