If your SQL Server ever crashes or hard rebooted then you may come across corrupted SharePoint_Config database. Recently while doing a SharePoint 2010 development on my VM, I had to hard reboot my personal VM, and I had received dreaded cannot connect to the configuration database error while accessing my content web application.
Having seen this error many times before, I have tried all the usual suspects – http://support.microsoft.com/kb/823287 – IIS Web Site availability, IIS Application Pool Availability. IIS Application Pool Identity, and SQL Server availability. After carefully walking through all the diagnostic steps, I had noticed that “SharePoint_Config” database was in suspect mode.
I had never seen SQL Server database in suspect mode. Quick Google took me following links to fix this issue.
As it turned out, it’s not a SharePoint issue. Any SQL Server databases can be corrupted and gets in the suspect mode. Following steps would fix the suspect database mode issues. I am adding these steps on my blog for reference only. Real credit goes to above blogs. To fix SQL Server database suspect mode, we need to use the SQL Server’s emergency mode which allows you repair the database by reparing to last normal state.
After running following script on the Master database, SharePoint_Config database suspect mode was fixed and I was able to access the content web application.
-- Use the Master database Use Master -- Verify that database has issues EXEC sp_resetstatus 'SharePoint_Config' -- Put the database in emergency mode ALTER DATABASE SharePoint_Config SET EMERGENCY DBCC checkdb('SharePoint_Config') -- Set the database in single user mode ALTER DATABASE SharePoint_Config SET SINGLE_USER WITH ROLLBACK IMMEDIATE -- Repair the database with data loss DBCC CheckDB ('SharePoint_Config', REPAIR_ALLOW_DATA_LOSS) -- Set the database in multi-user mode ALTER DATABASE SharePoint_Config SET MULTI_USER -- Verify that database is reset EXEC sp_resetstatus 'SharePoint_Config'