SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 SQL Server Administration (2008)
 Database backup for different database
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

cidr
Posting Yak Master

United Kingdom
203 Posts

Posted - 10/19/2012 :  10:42:41  Show Profile  Reply with Quote
Hi there,

I know there is quite a few threads on this topic but can't for the life of me get this working.

I have a backup from a database (dbSource) and I want to use this backup and restore it to another database (dbTarget) which is at the moment emtpy.

I don't want to affect dbSource when I use this backup but I get errors saying I can't overwrite dbSrouce. I don't want to overwrite it... and don't want to touch this database.

I only want to use the back up to make a 'copy' of it over dbTarget.

Please can someone help me with this.

robvolk
Most Valuable Yak

USA
15663 Posts

Posted - 10/19/2012 :  11:06:09  Show Profile  Visit robvolk's Homepage  Reply with Quote
RESTORE DATABASE dbTarget FROM DISK='backup file location' WITH REPLACE
Note that if dbSource and dbTarget have different logical names for data and log files, you'll need to use the MOVE option in the RESTORE command:
RESTORE DATABASE dbTarget FROM DISK='backup file location' WITH REPLACE
, MOVE 'dbSource_Data' TO 'path to dbTarget MDF file'
, MOVE 'dbSource_Log' TO 'path to dbTarget LDF file'
Naturally it's a good idea to make a backup of dbTarget first, unless it's completely empty.
Go to Top of Page

cidr
Posting Yak Master

United Kingdom
203 Posts

Posted - 10/21/2012 :  09:54:19  Show Profile  Reply with Quote
@robvolk

With a bit of fiddling about and RESTORE FILELISTONLY, along with the code you supplied, I managed to get this working.

Thanks
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000