Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
cidr
Posting Yak Master
207 Posts |
Posted - 2012-10-19 : 10:42:41
|
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
15732 Posts |
Posted - 2012-10-19 : 11:06:09
|
[code]RESTORE DATABASE dbTarget FROM DISK='backup file location' WITH REPLACE[/code]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:[code]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'[/code]Naturally it's a good idea to make a backup of dbTarget first, unless it's completely empty. |
|
|
cidr
Posting Yak Master
207 Posts |
Posted - 2012-10-21 : 09:54:19
|
@robvolkWith a bit of fiddling about and RESTORE FILELISTONLY, along with the code you supplied, I managed to get this working.Thanks |
|
|
|
|
|