Is it possible to create a script that will generate a create table script for all tables in a database at once?

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

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

  • 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.
    General Disclaimer:
    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?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • You can use the Genereate Scripts option as shown in the following link:

    Generating Scripts in sql server[/url]

    Vinu Vijayan

    For better and faster solutions please check..."How to post data/code on a forum to get the best help" - Jeff Moden[/url] 😉

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply