How to copy database structure to another database in SQL Server 2008?

I have a database and you want to copy all the tables to a new database without copying the data of all these tables, only the structure should be copied

+7
source share
3 answers

SQL Server Management Studio offers the following:

The script for the entire database:

  • In the Object Explorer, right-click on the database and select Script Database as

In a script, only (specific) tables:

  • In the object explorer, right-click the database, select Tasks , then Generate Scripts , and then select the tables you want.

Then you can use the script to create a new database / new objects elsewhere. If you change the database name, be sure to change the USE xxx statement accordingly.

+2
source

In SSMS, for your first database, right-click on the name datbaase, then "Script Database as"> "CREATE To", then select your output location and run the script.

Edit:

Note that you will need to modify the script to specify a new database name, replacing the existing one in the generated script (kindly provided by the Oded remark).

0
source

In SQL Server Management Studio, you can right-click the database -> tasks -> export data. Then follow the wizard.

0
source

All Articles