Jaa


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

  1. On the View menu, click Template Explorer.

  2. 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.)

  3. 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

  1. On the File menu, point to New, and then click File.

  2. In the New File dialog box, in the Categories box, expand SQL Server Query, and then click Database.

  3. In the Templates box, click Create Database, and then click Open.

  4. 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

  1. On the Query menu, click Specify Values for Template Parameters.

  2. 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

  1. In Template Explorer, navigate to the node where you would like to store the new template.

  2. Right-click the node, point to New, and then click Template.

  3. Type the name for your new template and then press ENTER.

  4. 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.

  5. 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.

  6. On the toolbar, click Save to save your new template.

See Also

Other Resources

Creating Custom Templates
Using SQL Server Management Studio Templates

Help and Information

Getting SQL Server 2005 Assistance