Generating scripts of various objects in SQL Server
Management Studio (SSMS) is a common requirement and generating the
script for all the objects is a pretty straight forward task, which can
be done using a simple approach as detailed out this msdn article. However, let us say that you want to generate the create scripts for a selected set of tables in your database (say AdventureWorksDW database). How would you do it? Well, keep reading to know how :-)
-
Open SSMS, Connect to the SQL Server Instance
-
Go to Object Explorer, and expand Databases folder
-
Expand the data Database from which you want to script objects
-
Select the Tables folder
-
Go to View | Object Explorer Details (alternatively you can press F7). Now the Object Explorer Details looks as shown below.
-
Now, to generate Create Table Script for multiple selected objects in AdventureWorksDW database, select multiple tables in the Object Explorer Details (by holding Ctrl key).
-
Right click and select Script Table as | CREATE TO | New Query Editor Window as shown below.
This will generate the CRATE TABLE Script for all the objects selected in the Object Explorer Details window.
What approach do you use to perform this task?Note: Above demonstration is based on SQL Server 2008 R2 Management Studio.
No comments:
Post a Comment