Thursday, March 22, 2012

create a empty DB from a existing DB

how to: create a empty DB from a existing DB keeping all fields and keys intact

A clean way to create an empty database from an existing populated database is to script all the database objects in the database including Stored Procedures, Tables, User-defined data types and Views. Follow these steps in SQL Server 2005:

1. In SQL Server Management Studio, right-click the database and click Tasks > Generate Scripts...

2. Click the Next button on the Welcome dialog box.

3. Check the "Script all objects in the selected database" option and click the Finish button. The script will be generated and dumped into a query window.

4. Save the script as a SQL Server script file.

5. Run the script file on your destination server to recreate the database without the data.

Hope this helps.

|||Is there a way to generate scripts that also contain the data?

No comments:

Post a Comment