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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Renaming database

Status
Not open for further replies.

cocopud

Technical User
Jan 8, 2002
139
US
I was wondering if there is a way to rename a database along with the .mdf file. We renamed our database because we wanted to keep it as a sort of backup before we reinitialize the data. We have been testing with the data, so we now are starting from the original data, but I don't want to lose the other stuff in case the users wanted some of the old records.

Any Suggestions?
 
Check out the Books OnLine, use the Index tab, enter RESTORE DATABASE. Double-click on RESTORE DATABASE from the list, and select 'How to restore a database with a new name' from the list.

-SQLBill
 
Basically it uses the MOVE option.

current database= db1
new database= newdb
backup device=backupdb1

RESTORE DATABASE newdb
FROM backupdb1
MOVE 'db1_data' to 'c:/newdb_data.mdf'
MOVE 'db1_log' to 'c:/newdb_log.ldf'

Again, refer to the BOL for other information on doing this BEFORE you do it.

-SQLBill
 
Thanks, I will look that up. It looks like that will help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top