How to repair a SQL Server 2005 Suspect database
Posted by Manoj Garg on July 17, 2008
Sometimes when you connect to your database server, you may find it in suspect mode. Your database server won’t allow you to perform any operation on that database until the database is repaired.
A database can go in suspect mode for many reasons like improper shutdown of the database server, corruption of the database files etc.
To get the exact reason of a database going into suspect mode can be found using the following query,
DBCC CHECKDB (‘YourDBname’) WITH NO_INFOMSGS, ALL_ERRORMSGS
Output of the above query will give the errors in the database.
To repair the database, run the following queries in Query Analyzer,
EXEC sp_resetstatus ‘yourDBname’;
ALTER DATABASE yourDBname SET EMERGENCY
DBCC checkdb(‘yourDBname’)
ALTER DATABASE yourDBname SET SINGLE_USER WITH ROLLBACK IMMEDIATE
DBCC CheckDB (‘yourDBname’, REPAIR_ALLOW_DATA_LOSS)
ALTER DATABASE yourDBname SET MULTI_USER
and you are done.
You should keep one thing in mind while using the above queries that the repair mode used here , REPAIR_ALLOW_DATA_LOSS, is a one way operation i.e. once the database is repaired all the actions performed by these queries can’t be undone. There is no way to go back to the previous state of the database. So as a precautionary step you should take backup of your database before executing above mentioned queries.
Ha-P Querying…


Deepali said
Can ay one help me to find out reasons of database going to suspect mode,in sql server 2005.
bijendra rajput said
yes i can help you.
A database can go in suspect mode for many reasons like improper shutdown of the database server, corruption of the database files etc.
Ben said
Thanks for this one. Saved me quickly.
Maurizio said
Thank you very much for the suggested solution!! It worked great
Manoj Garg said
Glad that it helped you.
AdoSK said
Dakujem, dakujem, dakujem (Slovak language). International – Thank, thank, thank. I’m very happy NOW. I’m thought, that I’m in ass. Thank
Mohit Garg said
Great Man it worked for me as well…
saufi said
thanks, great code
Gilberto said
I´m brazilian, and used this code and my data base it´s alive! Thanks a lot!! Não tenho mais palavras para agradecer ao postador deste código!! Obrigado mesmo!!! Merece um grande beijo (not gay, please…:))
Reparar uma tabela marcada como suspect no SQL Server 2005 | David Ruiz said
[...] Neste site encontrei um procedimento que funcionou perfeitamente! Lembre-se: O risco é seu ao executar o código abaixo! EXEC sp_resetstatus ‘MINHA_TABELA‘; [...]
Alex said
In this situation advise use this tool because it is very good also it has free status as far as i know-mssql repair,tool
can help with this problem and retrieve the data, that was considered to be lost,mwill extract housekeeping data from the source database and preview the data, that can be recovered,this tool is a good solution to recover data from corrupted databases in MS SQL Server format,restore databases represent files, like any other documents, they can be easily corrupted by viruses, all sorts of malware, hard drive failures, file system errors, incorrect user actions, etc,supports both data extraction to your hard drive as scripts in SQL format and data export directly to a database in MS SQL Server format.
Srgrn said
It worked like a charm, great
Thanks man
prashanth said
thankyou
sagitariusmzi said
This solution doesn’t worked for me,
when i executed the above mention queries, it given me lot of errors ?
Shahid Khan said
great Code From Great Man it worked Excellent…
Deepanshu Jouhari said
One More Saved, Really required this information on net.
Thanks
Susannah said
Saved my life..Thanks…I’ll be taking more regular backups from now on
Munya Chaunza said
It worked thank you.
Ahsan said
Saved my life..Thanks…
David said
Your Query is helpful but sometime when database is badly corrupted then this query is not helpful then during that time you need to use third party tool as SQL Recovery which repair and recover lost data, tables, views, stored procedures, rules, defaults, user defined data types and triggers from Microsoft SQL server database.
Madhu K said
Hi,
Thanks for the code, it resolved my DB suspect mode issue.
Rob said
You saved the day. Thanks
Allan Connolly said
Thanks for a great piece of code, saved me an absolute ton of time
thanks
Allan
bsking said
It saved the day for me. thanks a ton.
Antonio said
thanks, it helped!
just a notice for novice users: it will delete some records! in my case, i had 4 screwed invoices. after deleting them and all their records (invoice records, stock movement, equipment serial numbers, etc) in the SQL Manager, i was able to proceed with my life.
M Arif Iqbal said
Dear Friend
Your code is very simple and very effective it help me a lot. I have resolved many suspect even damage sql server 2005 databases with it. Keep your good work going. With best wishes.
Sometimes part of the disk is damage or it develop bad block due to this we can not backup or copy the database use http://www.anyreader.com/ to copy the data.
GmE said
Great code & effective, works fine with me.
Thanksssssssssssss!
aasim abdullah said
impressive post
Chris A said
Many thanks Manoj – worked really well for me.
Online Stock Investing said
Hey, I read a lot of blogs on a daily basis and for the most part, people lack substance but, I just wanted to make a quick comment to say GREAT blog!…..I”ll be checking in on a regularly now….Keep up the good work!
Online Stock Trading said
Hey very nice blog!!….I’m an instant fan, I have bookmarked you and I’ll be checking back on a regular….See ya
Alex said
It worked perfectly! Thanks for it!
TONYE said
Fantastic page Manoj!
Worked first time and helped the user get productive in minutes!
gVa Solutions said
This saved my vSphere Virtual Center server database – thanks!
Suresh said
Cool. I tried all possible way but end up seeing something like “Your DB is in suspect mode and you can’t do this”.
But, my DB just obeyed your code and its now recovered.
Great! What I learned today is this!
Ramani Sandeep said
great post.. helpd a lot..
Eduardo Aguirre said
Thanks for your help