Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

restoring a database

Status
Not open for further replies.

stiej

Technical User
Jan 20, 2003
142
GB
Hi,

I have two databases a "primary" one and a secondary one.

Using SQL code, what do I type to drop the secondary one and restore this secondary one from the primary one whilst leaving the primary one untouched? In other words, to duplicate the primary databse with a new name?

Any help much appreciated!

Steve
 
Dropping a database is easy:

DROP DATABASE database_name

Copying the primary to the secondary is tougher. I suggest refering to the BOL, use the Index tab and enter:

Copy Database Wizard

and then

Copying databases
- then click on Overview.

The first option will give you information on using the wizard to do the copy for you and the second will give you the information on how to do it yourself.

-SQLBill

BOL = MS SQL Server's Books OnLine = MS SQL Server's Help
Installed as part of the Client Tools
Found at Start>Programs>Microsoft SQL Server>Books OnLine
 
You can backup the primary and restore it over the secondary - you can drop the secondary first but it's not necessary.

See backup database and restore database with move in bol.

It is easiest if you do the backp to a file rather than a dump device.
This also gives you a test of the backup.

======================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top