Tuesday, 14 July 2015 00:00

How to repair a SQL Server 2005/2008 database in suspect mode

Rate this item
(0 votes)
This can happen following things like hardware failure, power outages, database files being locked by the Operating System (Anti-Virus, backup software etc.) or actual corruption of the database.

Attempting the repair procedure below is really a last resort.  If you have good and recent backups, then if at all possible I would perform point-in-time recovery of the database concerned, as this emergency repair can (as the name suggests) result in data loss.

If you’ve gone through all of this like I once did though, and all other avenues failed, here are the steps that fixed it for me:
EXEC sp_resetstatus 'YourDBName'
ALTER DATABASE 'YourDBName' SET EMERGENCY
(You won’t be able to query the database until it’s in EMERGENCY mode!)
DBCC CHECKDB ('YourDBName')
ALTER DATABASE YourDBName SET SINGLE_USER WITH ROLLBACK IMMEDIATE
DBCC CHECKDB ('YourDBName') WITH NO_INFOMSGS, ALL_ERRORMSGS
DBCC CHECKDB ('YourDBName', REPAIR_ALLOW_DATA_LOSS)
ALTER DATABASE YourDBName SET MULTI_USER
In the end, I just had to rebuild a couple of indexes after the repair process and everything was recovered….phew!
ALTER INDEX ALL ON [YourTableName] REBUILD
Again, it’s worth stressing that this is a last resort – use a good backup/standby etc. first, if you have one!
Last modified on Tuesday, 14 July 2015 14:31
Data Recovery Expert

Viktor S., Ph.D. (Electrical/Computer Engineering), was hired by DataRecoup, the international data recovery corporation, in 2012. Promoted to Engineering Senior Manager in 2010 and then to his current position, as C.I.O. of DataRecoup, in 2014. Responsible for the management of critical, high-priority RAID data recovery cases and the application of his expert, comprehensive knowledge in database data retrieval. He is also responsible for planning and implementing SEO/SEM and other internet-based marketing strategies. Currently, Viktor S., Ph.D., is focusing on the further development and expansion of DataRecoup’s major internet marketing campaign for their already successful proprietary software application “Data Recovery for Windows” (an application which he developed).

Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

Get Help Now

Thank you for contacting us.
Your Private Investigator will call you shortly.