Tips ‘N’ Tricks – SSMS – Generate Script for Multiple Select Objects in One-Go

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.

Object Explorer with List of Tables in SSMS

  • 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.

Generate Script for Multiple Objects in One Shot in SSMS

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.

Take a look at the other Tips and Tricks in this Series on Tips, Tricks, Techniques, and Shortcuts to Improve Productivity, and Design and Coding Skills.

Advertisements

About Dattatrey Sindol (Datta)

Datta is a Microsoft BI Enthusiast, passionate developer, and a blogger. View Full Profile

Posted on June 14, 2012, in SQL Client Tools, SQL Server, SSMS, SSMS Tips, T-SQL, T-SQL Tips, Tips 'N' Tricks and tagged , , , , , , , , . Bookmark the permalink. 1 Comment.

What are your thoughts?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: