Copying databases in SQL Server 2005 and SQL Server 2008

Tags:
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?
ASKED: July 28, 2008  3:39 PM
UPDATED: July 28, 2008  8:42 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

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.

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following