1

When I try to restore my database with

RESTORE DATABASE MyDatabase
FROM DISK = '\path\to\my\backup.bak'
WITH REPLACE, RECOVERY

It says

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

After some googling I tried this instead:

ALTER DATABASE MyDatabase SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
RESTORE DATABASE MyDatabase
FROM DISK = '\path\to\my\backup.bak'
WITH REPLACE, RECOVERY
GO

However, this seemed to take forever and when I eventually cancelled the command it told me that

Nonqualified transactions are being rolled back. Estimated rollback completion: 0%.

The message repeated multiple times and the progress was always 0%.

I'm not a DBA --sadly my company does not employ any-- and I have no clue where to go from here.

1 Answer 1

7

If you can restart the SQL Server service, then:

  • Stop the SQL Server service
  • Delete the old data/log files for MyDatabase
  • Start the SQL Server service again
  • At that point, you can delete the (offline) database
  • Do your restore
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.