Wednesday, August 3, 2011

Recover SharePoint Site from suspect database

 When Central Administration in SharePoint 2010 stops abruptly and its Content/Config database switches itself automatically to Suspect mode for no apparent reason, that too after a very stressful and super-hard working day for me.


To recover your sharepoint site from suspect database use following steps:-


1. Go to your MSSQL\Data files that reside under: C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA

2. Identify your Central Admin Content Database name in my case it got screwed up and was in the suspect: mode: so this is my content database name WSS_Content_13885.

NOTE: Please take a backup of the corrupted .mdf and .ldf files, before following other steps

3. Open your SQL Server Management Studio ->, New Query and it opens up your SQL Query editor, copy and paste the query below and change the highlighted to your database name

--Verify whether Database has any issues
EXEC sp_resetstatus
"WSS_Content_13885"

---Alter database and put it on Emergency Mode
ALTER DATABASE "
WSS_Content_13885" SET EMERGENCY
DBCC checkdb
('WSS_Content_13885')

--Set the database in the Single User mode
ALTER DATABASE "
WSS_Content_13885" SET SINGLE_USER WITH ROLLBACK IMMEDIATE

--Repair the database and allow data loss
DBCC CheckDB
('WSS_Content_13885',REPAIR_ALLOW_DATA_LOSS)

--Set the database back to Multi-User mode
ALTER DATABASE
"WSS_Content_13885" SET MULTI_USER

--Ensure Database is reset
EXEC sp_resetstatus
,WSS_Content_13885'.

Execute all the commands in your SQL Query Editor and there you go, Go back to your SQL Management Studio and you can see that the (Suspect) mode issue against the Content/Config database is fixed and the database got fully repaired and restored.

To verify the same, hit your Central Administration and it starts working just fine...