Wednesday, April 17, 2019

SQL Database is in "Pending Recovery" state

https://www.stellarinfo.com/blog/fix-sql-database-recovery-pending-state-issue/


--Option1
----------------------------------------------------

ALTER DATABASE [DBName] SET EMERGENCY;

GO

ALTER DATABASE [DBName] set single_user

GO

DBCC CHECKDB ([DBName], REPAIR_ALLOW_DATA_LOSS) WITH ALL_ERRORMSGS;

GO

ALTER DATABASE [DBName] set multi_user

GO

------------------------------------------------------------------
--Option2



ALTER DATABASE [DBName] SET EMERGENCY;

ALTER DATABASE [DBName] set multi_user

EXEC sp_detach_db ‘[DBName]’

EXEC sp_attach_single_file_db @DBName = ‘[DBName]’, @physname = N'[mdf path]’

No comments:

Post a Comment