Question

Asked:
Asked By:
Jul 28 2008   3:39 PM GMT
SQL Server Ask the Experts   2275 pts.

Copying databases in SQL Server 2005 and SQL Server 2008


SQL Database, SQL Server 2005, SQL Server 2008

In SQL Server 2005 and SQL Server 2008, the CREATE DATABASE function creates a new database and copies all the tables that are present in the model database. Is there a function where I can do the same from a template database?

Subscribe to Alerts! Get questions and answers delivered to your Inbox.


E-mail me updates on this question



   SUBSCRIBE

hidden modal window

Answer Wiki (Improve, edit or add to this answer)


 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0



You have a couple of options here.

1. Create a backup of the sample database, and instead of using the CREATE DATABASE command use the RESTORE DATABASE command and restore the backup of the template to the new database.

2. Add the objects you want in every database into the model database.

If you have more than one server to deal with, and you want them to all use the same template then use option #1 so that you always use the same template backup for each server. You could even save the backup script so that you just change the database name in the script and run the script and your restore would kick off.
  • AddThis Social Bookmark Button

Browse more Questions and Answers on SQL Server.

Looking for relevant SQL Server Whitepapers? Visit the SearchSQLServer.com Research Library.


Discuss This Answer


You must be logged-in to discuss a question. Log-in/Register

Mrdenny   41270 pts.  |   Jul 28 2008  8:42PM GMT

Check out my SQL Server blog “SQL Server with Mr Denny” for more SQL Server information.