Tip: Using SQL Server Query Analyzer Templates


SQL Server Query Analyzer templates offer a great way for novices to quickly write SQL scripts for specific tasks. SQL Server 2000 includes boilerplate templates that provide the basic SQL you need to script specific activities. SQL Server 2000 includes 62 templates across 13 categories. For example, the Create Table group provides the following seven templates:

  • Create Table Basic Template.tql
  • Create Table Specifying Constraints.tql
  • Create Table Specifying File Groups.tql
  • Create Table with Computed Column.tql
  • Create Table with IDENTITY Column.tql
  • Create Table with ROWGUIDCOL Column.tql
  • Create Temp Table.tql

Suppose you wanted to use the Create Table with Computed Column.tql template. Simply open Query Analyzer and select Insert Template from the Edit menu. From the Create Table group, select Create Table with Computed Column.tql, which places in your Query Analyzer window the script that Listing A shows. You can then select Replace Template Parameters from the Edit menu, which brings up a dialog box that lets you replace template placeholders with values specific to your implementation.

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.