Saturday, 26 November 2011

Query to Restore a database from backup in MSSQL

Hello friends,

I had an issue in restoring a database from backup in MSSQL. Finally after a long struggle i fixed the issue by executing the following query.

----------
Use Master

Alter Database databasename
SET SINGLE_USER With ROLLBACK IMMEDIATE

RESTORE DATABASE databasename

FROM DISK = 'backup location'
WITH REPLACE;

Alter database databasename
SET MULTI_USER;

----------- 


If you have any similar issue, try this.


Thank you.


Regards,
Nivas.B.

No comments: