Templates in SQL Server

Source: Internet
Author: User
Tags sql server query
At noon today, I asked a mm question. What does CREATE TABLE <table_name, sysname, test_table> mean? I have never seen it before, but I have no choice but to Google. It is really hard to find the information, but I finally found it. I installed SQL Server and tried it again. I can basically verify my understanding.
It turns out that the SQL Server 2000 query analyzer provides a template library that can be used to create tables, views, and stored procedures.
Author: builder.com
Open the query analyzer and open its Object Browser. You will see two tabs at the bottom of the browser. Click the template tab and you will see many available templates. Double-click a template of the task, and the query analyzer opens a new query window. Then, paste the Template into this window. You can also see it in the edit-> insert template. You can find these templates in the Program Files \ Microsoft SQL Server \ 80 \ tools \ Templates \ SQL query analyzer folder, which contains 13 subfolders, each subfolders contains templates dedicated to specific tasks (such as create table. Each folder contains several templates. The following is one of the create database templates:

-- ===================================================== ======
-- Basic create database template
-- ===================================================== ======
If exists (select *
... From Master... sysdatabases
... Where name = n' <database_name, sysname, test_db> ')
... Drop database <database_name, sysname, test_db>
Go

Create database <database_name, sysname, test_db>
Go

CodeBrackets in indicate replaceable tags. The replace template parameter command in the query analyzer editing menu calls up a dialog box in which all parameters can be replaced at one time. Note: The shortcut for opening this dialog box is [CTRL] [shift] M.

It may not be obvious that you can combine several templates into a stored procedure. When the first template is in its editing window, you only need to drag other templates to the same window.

Many organizations have their own standards when managing the style, indentation, and title of stored procedures. This is where you experience the real power of templates. Load existing templates to your preferred text editor to customize existing templates. Even better, you can create a folder in the SQL Server Query analyzer folder and put your template in the new folder. They will automatically appear in the browser window of the object for query and analysis. The Delete and update actions have no corresponding template; however, you can write templates for such actions and place them in the SQL Server Query analyzer folder.

If you work in a multi-person development environment, you can tell the query analyzer to search for its template elsewhere (such as shared folders on the network. From the query analyzer menu, select Tools | option and edit template directory settings.

If you have not used these templates, I suggest you use them. You will find that this can save a lot of time for typing on the keyboard. If you perform some custom operations, you can also automatically abide by the Organization's standards.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.