Thursday, February 14, 2013

Suspect Database in SQL Server



If your database is in suspect mode there are several possible reasons:

1. You do not have enough space available so the SQL Server can recover the database during startup
2. Your Database might be corrupted
3. Maybe there is no enough memory
4. Possible hardware failure.
5. The Database files are held by other programs

To try to solve this problem following the next steps, but before I encourage you to make a copy of your database file, because in the process you could loss some data and there is no way to go back to the previous state.

STEP 1.- Put the database in EMERGENCY mode so you can manipulate the database

USE master
GO 

ALTER DATABASE mydb SET EMERGENCY
GO



STEP 2.- Put the database in single user mode, so nobody can interfere with the process
ALTER DATABASE mydb SET SINGLE_USER WITH ROLLBACK IMMEDIATE 
GO



STEP 3.- Try to repair the data base
DBCC CHECKDB (mydb, REPAIR_ALLOW_DATA_LOSS) 
GO



STEP 4.- Return the database to a multi user so it can be accessed
ALTER DATABASE mydb SET MULTI_USER
GO


Now you database should be ready to be used; check the logs so you can fix any problems found.

No comments:

Post a Comment