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.
- Stored procedures and triggers can implement directly without the third party compiler.
- These stored procedures and triggers can be run on any database server regardless operating system.
- No additional files are needed to deploy.
- Scripts are time saving means that a number of commands can execute sequentially.
Disadvantages of Using the SQL Server Scripts
- The functionality supported by SQL Scripts may not sufficient for all situations.
- The debugging process of complicated SQL scripts is difficult.
- 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.
- Go to the Object Explorer, expand Databases, right-click and select the Generate Scripts.
- Select the objects from Choose objects page.
- Now, select Save Scripts to a desired location from Set Scripting Options.
- 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.
- You can monitor the progress of the SQL Script generation from the Save or Publish SQL Scripts page.
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.
Using Object Explorer Script as Menu
Follow the given steps to create SQL Scripts:
- Go to the Object Explorer, select the category node of the types of object you want to script.
- Now open the Object Explorer Details pane by using F7, or by using the View menu.
- Left-click on the selected object that you want to script.
- To script another object press and hold the Ctrl key and left-click on the second object which you want to script.
- Now right-click on the selected objects, and choose Script object type as.
Conclusion
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
EmoticonEmoticon