Search This Blog

How to Repair Suspected Database in SQL

 Repair Suspected Database in SQL

Some times your database goes to Suspect mode in that you cannot work on Database anymore

The Possible Reason of Suspected Database.
1-Database files has been corrupted
2-Insufficient Memory or Space in your Drive.
3-Hardware Failure
4-Unexpectdly  Shut Down of SQl Server or Sql Services.
5 Sometimes Moving Database files to other Location.

In order to Recover the Database from Suspected Mode

First way

ALTER DATABASE db_name SET EMERGENCY

This query will set ur Database to Emergency Mode 

Restore the Latest Backup

Then your Database will work

2-If you don't have Recent Back UP

You can Run this Query

EXEC sp_resetstatus [DatabaseName];

ALTER DATABASE [DatabaseName] SET EMERGENCY

DBCC checkdb([DatabaseName])

ALTER DATABASE [DatabaseName] SET SINGLE_USER WITH ROLLBACK IMMEDIATE

DBCC CheckDB ([DatabaseName], REPAIR_ALLOW_DATA_LOSS)

ALTER DATABASE [DatabaseName] SET MULTI_USER

It will bring your DB back to Normal state but there are possibility that while conversion some of your data can be lost.

Note : In the 2nd Solutions there Might be chances that some of Data can be loss while Repairing so make sure ur not running this in Production server or when  you can afford data loss then only run the second option.

No comments:

Post a Comment