Basics of SQL Server Script - An Overview

What is SQL Server Script?

The SQL script is a collection of SQL statements that is saved as an .sql file. We can use the SQL Scripts for creating, editing, viewing, running, and deleting records.

SQL script provides a convenient way to move complex processes to the server and the ideal platform for the implementation of stored procedures.

Advantages of SQL Script in Database

Implementing the stored procedures or triggers using a SQL Script provides the following advantages over external library.

  1. Stored procedures and triggers can implement directly without the third party compiler.
  2. These stored procedures and triggers can be run on any database server regardless operating system.
  3. No additional files are needed to deploy.
  4. Scripts are time saving means that a number of commands can execute sequentially.

Disadvantages of Using the SQL Server Scripts

  1. The functionality supported by SQL Scripts may not sufficient for all situations.
  2. The debugging process of complicated SQL scripts is difficult.
  3. SQL Scripts cannot make a system call.

How to Create SQL Server Script

There are two methods to create a SQL Server Scripts in SSMS. One is by using “Generate and Published Scripts Wizard” and the other is by using “Object Explorer Script as Menu”. SQL Server Database Script is created in the ANSI Unicode format.

Using Generate and Publish Script Wizard

Follow the given steps to create a SQL Server Script using Generate and Publish Wizard.

  1. Go to the Object Explorer, expand Databases, right-click and select the Generate Scripts.
  2. Select the objects from Choose objects page.
  3. Now, select Save Scripts to a desired location from Set Scripting Options.
  4.     a. For the advanced scripting options, click on the Advanced button.
        b.Select the location: a file, Database Engine Query Editor window, or the Clipboard for the generated script.

  5. Now, review your selections on Summary page. To change the selection, click on the previous button. To generate a script of selected objects click on Next.
  6. You can monitor the progress of the SQL Script generation from the Save or Publish SQL Scripts page.

Using Object Explorer Script as Menu

Follow the given steps to create SQL Scripts:

  1. Go to the Object Explorer, select the category node of the types of object you want to script.
  2. Now open the Object Explorer Details pane by using F7, or by using the View menu.
  3. Left-click on the selected object that you want to script.
  4. To script another object press and hold the Ctrl key and left-click on the second object which you want to script.
  5. Now right-click on the selected objects, and choose Script object type as.


In this article we have discussed about the SQL Server Script and advantages and disadvantages Scripts. This article also describes how to create SQL Server database script using Generate and Publish Script Wizard and Object Explorer Script as Menu

Next Post »