Wednesday, April 1, 2009

Exclusive access could not be obtained because the database is in use

Issue: Exclusive access could not be obtained because the database is in use
Solution:

Use Master

Alter Database YOURDB
SET SINGLE_USER With ROLLBACK IMMEDIATE


RESTORE DATABASE YOURDB
FROM DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL\BACKUP\YOURDB.bak'

No comments: