Side by Side Databases
Let's say you forgot a WHERE clause and want to restore your backup database to recover the lost data. However, you don't want to override the data that has accumulated since the last back-up. What you need to do is restore the backup along side the newer database. Here is how to do it:
RESTORE DATABASE backup
FROM 'C:\temp\lastbackup.bak'
WITH MOVE 'mydb_Data' TO 'C:\MySQLServer\backupdb.mdf',
MOVE 'mydb_Log' TO 'C:\MySQLServer\backupdb.ldf';
This statement tells the SQL server to create a database called "backup", from the lastbackup.bak file and not to use the files stored in the back-up, but instead use: backupdb.mdf and backupdb.ldf. Unless you remap your backup files, the RESTORE will try to override the old files that are in use by the newer database -- which will cause a SQL Server error (not data loss).
{6230289B-5BEE-409e-932A-2F01FA407A92}
Comments
Post a Comment