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 09, 2012 11:09 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, February 26, 2014 1:28 PM
Points: 280, Visits: 622
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 09, 2012 11:24 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, February 26, 2014 1:28 PM
Points: 280, Visits: 622
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 09, 2012 11:27 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 9:16 PM
Points: 2,763, Visits: 5,915
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.
I am a great believer in luck, and I find the harder I work the more I have of it. Stephen Leacock

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: Tuesday, April 08, 2014 2:40 AM
Points: 1,118, Visits: 1,573
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