MS SQL db suspect fix

Recover MS SQL from suspect mode,

due to some reasons (low disk space issue, sudden poser failure, log file missing, etc) db can be goes in to suspect mode.

This shows that your db having some issue in it.

To check which database is in suspected mode in command line.

 

USE master

GO

SELECT NAME,STATE_DESC FROM SYS.DATABASES
WHERE STATE_DESC=’SUSPECT’
GO

Steps to fix the suspected database.

 

Step 1 :  change db status to EMERGENCY MODE
 

USE master
GO

ALTER DATABASE ‘db_name‘ SET EMERGENCY
GO

 

Step 2 : Perform Consistency check using this command
 
DBCC CHECKDB (db_name)
GO
Step 3 : bring database in to SINGLE_USER mode
 
USE master
GO

ALTER DATABASE db_name SET EMERGENCY
GO
Step 4 : Execute DBCC CHECKDB to check the physical and logical integrity
 

USE master
GO

DBCC CHECKDB (db_name)
GO

it will take time, that depends upon the size of db.
Step 5 : Bring the database in to SINGLE_User mode
 

USE master
GO

ALTER DATABASE db_name SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO

Step 6 : When the database in to SINGLE_User mode

 

USE master
GO

DBCC CHECKDB (db_name, REPAIR_ALLOW_DATA_LOSS)
GO

Step 7 : Finally change SINGLE_User mode to MULTI_USER
 

ALTER DATABASE db_name SET MULTI_USER
GO

Leave a Reply

Your email address will not be published. Required fields are marked *