Tuesday, August 23, 2011

How To Repair SUSPECT Database

Sometimes we see a SharePoint error "Cannot connect to the configuration database". One of the reasons for this could be the Respective DataBase is set to SUSPECT mode.

Reasons for database SUSPECT state:
1. Database corruption.
2. Not enough space for the SQL Server to recover the database during startup.
3. Insufficient memory or disk space.
4. Unexpected SQL Server Shutdown, Power failure or a Hardware failure.

Follow the below steps to repair the SUSPECT database:
1. Identify all the databases which are in SUSPECT mode
USE master
GO
SELECT NAME,STATE_DESC FROM SYS.DATABASES
WHERE STATE_DESC='SUSPECT'
GO
Note:Check the latest log for the database which is marked as suspect.
SQL Server -> Management -> SQL Server Logs

2. Get the database first into EMERGENCY mode to repair it
USE master
GO
ALTER DATABASE "databasename" SET EMERGENCY
GO
Note: The EMERGENCY database is one way which means read-only.

3. Repair the Database in emergency mode
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

No comments:

Post a Comment