cheryl9063
asked on
sql restore from 2 .bak files
What is the correct syntax. I need to restore one database called hat but I have 2 .bak files that need to be restored for 1 database. See my code below.. What is the correct way to write this?
RESTORE FILELISTONLY FROM disk = N'E:\Backups\hat0.bak'
RESTORE FILELISTONLY FROM disk = N'E:\Backups\hat1.bak'
-- Perform the restore of the database from the backup file.
-- Replace 'move' names (MDFLogicalName, LDFLogicalName) with those found in
-- the previous filelistonly command
restore database hat
from disk = N'E:\Backups\hat0.bak' and N'E:\Backups\hat1.bak'
with move 'hat_Data' to 'J:\MDFs\hat.mdf',
move 'hat_Log' to 'I:\Data\hat.ldf',
replace, stats=10;
RESTORE FILELISTONLY FROM disk = N'E:\Backups\hat0.bak'
RESTORE FILELISTONLY FROM disk = N'E:\Backups\hat1.bak'
-- Perform the restore of the database from the backup file.
-- Replace 'move' names (MDFLogicalName, LDFLogicalName) with those found in
-- the previous filelistonly command
restore database hat
from disk = N'E:\Backups\hat0.bak' and N'E:\Backups\hat1.bak'
with move 'hat_Data' to 'J:\MDFs\hat.mdf',
move 'hat_Log' to 'I:\Data\hat.ldf',
replace, stats=10;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Step 1 - Retrieve Logical File Name
RESTORE FILELISTONLY
FROM DISK = N'E:\Backups\hat0.bak'
GO
Step 2 - Change to Single user Mode
ALTER DATABASE Hat
SET SINGLE_USER WITH
ROLLBACK IMMEDIATE
Step 3 - Restore Database
RESTORE DATABASE Hat
FROM DISK = N'E:\Backups\hat0.bak'
WITH MOVE 'Hat_Data' TO 'J:\MDFs\hat.mdf',
MOVE 'Hat_log' TO 'I:\Data\hat.ldf'
ALTER DATABASE Hat SET MULTI_USER
Repeat Step 1 thru 3 for second back up file