How To Fix "Cannot detach a suspect or recovery pending database. It must be repaired or dropped." Error



TODO:

Have you ever received the error "Cannot detach a suspect or recovery pending database. It must be repaired or dropped." when trying to detach a database that is suspect?

 

SOLUTION:

ALTER DATABASE MyDB SET EMERGENCY;
GO
ALTER DATABASE MyDB set single_user
GO
DBCC CHECKDB (MyDB, REPAIR_ALLOW_DATA_LOSS) WITH ALL_ERRORMSGS;
GO
ALTER DATABASE MyDB set multi_user
GO

 

NOTES:

Once that is done, you can then detach, and attach, or just bring online.

How To Fix A Database Stuck In [Recovery Pending] Status In SQL Server Management Studio



TODO:

SQL Server Management Studio reports a database in "Recovery Pending" status. 

 

SOLUTION:

use master

ALTER DATABASE YourDatabase SET OFFLINE WITH ROLLBACK IMMEDIATE
ALTER DATABASE YourDatabase SET ONLINE WITH ROLLBACK IMMEDIATE


NOTES:

There are no notes on this topic.