Labels

Sunday, 10 January 2016

SQL DBA : Troubleshooting database suspect mode issues in SQL Server

Problem 

My database went to suspect mode then how can I resolve it ?

Cause  :

Database will go to Suspect mode due to various reasons which are listed below .

If 

Database files are corrupted or there is disk issue . 

Database restoration process was failed unexpectedly .

If data file was full.

After detach and attach the actual files path is not recognized by SQL Server when you ran sp_helpdb

Solution

First Check the error logs to identify the route cause

1. If the data file was damaged or disk failure then db engine issues 17204 error

Take tail log backup

Restore full backup with No Recovery 

Restore recent differential backup with No Recovery 

Restore all log backups if any made after recent differential backup with No Recovery 

Restore tail log backup with Recovery .

2. If the log file was damaged then db engine issues 17207 error 

Try to take tail log backup with another copy of log file if available with RAID level .

If the log file is not available then make it online by running the following commands where there may be data loss .

Step 1: Make the db into single user .

Alter database < database name > set sing_user  with rollback immediate

Step 2 : Set the db into emergency mode .

Alter database < database name > set emergency

Step 3 :  Run the check db with required repair level

DBCC CHECKDB ('Database Name', REPAIR_ALLOW_DATA_LOSS)

Step 4 : Set the db into multi user mode .

Alter database < database name > set multi_user

No comments:

Post a Comment