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.
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.
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.
- Tips ‘N’ Tricks – SSMS – Script your actions in SSMS to Easily Generate T-SQL Scripts
- Tips ‘N’ Tricks – SSMS – Quickest way to Get Row Count of All Tables from a SQL Server Database
- Tips ‘N’ Tricks – SSMS – Quickest way to SELECT and Query All Columns from a Table in SQL Server
- Tips ‘N’ Tricks – SSMS – Easy way to Learn Keyboard Shortcuts by Enabling ScreenTips
- Tips ‘N’ Tricks – SSMS – Save Your Frequently Used Servers and Databases
- Tips ‘N’ Tricks – SSMS – Execute Single Query against Multiple Servers
Posted on June 14, 2012, in SQL Client Tools, SQL Server, SSMS, SSMS Tips, T-SQL, T-SQL Tips, Tips 'N' Tricks and tagged Databases, Object Explorer Details, Script, Shortcuts, SQL Server, SQL Server Management Studio, SSMS, T-SQL, Tips and Tricks. Bookmark the permalink. 1 Comment.