Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Is it possible to create a script that will generate a create table script for all tables in a database at once? Expand / Collapse
Author
Message
Posted Friday, November 9, 2012 11:09 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, October 16, 2014 2:40 PM
Points: 336, Visits: 757
Say I have a database called MyDB with 100 tables. I need to create these tables on another db. Is there a TSQL script that will return the create table scripts for all tables on MyDB?
Post #1383156
Posted Friday, November 9, 2012 11:24 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, October 16, 2014 2:40 PM
Points: 336, Visits: 757
I ended up using the Transfer SQL Server Objects task in ssis to copy the tables over without the data which is exactly what I needed.
Post #1383164
Posted Friday, November 9, 2012 11:27 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Yesterday @ 10:34 PM
Points: 3,749, Visits: 8,417
In SSMS you can right click on the database and use Tasks-> Generate Scripts...
That will give you plenty of options to generate the scripts for all or some of the objects of your database.



Luis C.
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1383165
Posted Monday, November 12, 2012 2:22 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, October 16, 2014 1:46 PM
Points: 1,127, Visits: 1,597
You can use the Genereate Scripts option as shown in the following link:

Generating Scripts in sql server


Vinu Vijayan

For better and faster solutions please check..."How to post data/code on a forum to get the best help" - Jeff Moden
Post #1383558
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse