Monday, 6 April 2015

Restore .bak file to Database

If I have a .bak file and I want to restore it database what are the various steps involved in it. Assume that I do not know much about that backup file.

‐‐Retrieve logical file name

RESTORE FILELISTONLY FROM DISK = 'D:\wave.bak'
GO

‐‐Make Database to single user Mode

ALTER DATABASE wave SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO

‐‐Restore Database

RESTORE DATABASE wave
FROM disk = 'D:\wave.bak'
WITH MOVE 'Best' TO 'd:\wave.mdf',
MOVE 'Best_log' TO 'd:\wave_log.ldf'
GO

‐‐Make Database to multi user Mode

ALTER DATABASE wave SET MULTI_USER
GO


No comments:

Post a Comment