Click here to Skip to main content
6,293,171 members and growing! (12,363 online)
Email Password   helpLost your password?
Database » SQL Reporting Services » General     Advanced

How to Restore SQL Server 2005 Suspect Database

By Suvendu Banik

How to Restore SQL Server 2005 Suspect Database
SQL, Windows, Visual Studio, SQL 2005, DBA, Dev
Posted:4 Sep 2007
Updated:13 Sep 2007
Views:53,650
Bookmarked:23 times
Unedited contribution
Announcements
Loading...
 
Search    
Advanced Search
printPrint   Broken Article?Report       add Share
  Discuss Discuss   Recommend Article Email
22 votes for this article.
Popularity: 4.82 Rating: 3.59 out of 5
5 votes, 22.7%
1

2

3
3 votes, 13.6%
4
14 votes, 63.6%
5

Introduction

If your project's Database is in suspect mode, then no transaction will take place until and unless you repair your database. That causes a show stopper for your up and running application. Here, you will find a way to get out of this.

Background

Your Database is in Suspect Mode. I Guess, you haven't experienced this problem till now. But, if it comes to you and if the database is in LIVE, then its time to read this article to get out of this tension.

Using the code

If you find your Database in Suspect mode then please keep your nerve strong. Just proceed step by step what I am written bellow. I think you will get out of this trouble. SQL Server 2005 introduced a new DB Status called Emergency. This mode can change the DB from Suspect mode to Emergency mode, so that you can retrieve the data in read only mode. The steps are... After executing the script given below you will get back your Database in operational mode. Actually I have tried with two of my existing live system and found no data loss.


Note: Obviously there is two more option available. run REPAIR_ALLOW_DATA_LOSS to ensure the database is returned to a structurally and transitionally consistent state. Here are a few things to bear in mind about emergency mode repair: it's a one-way operation. Anything it does cannot be rolled back or undone. If this worries you (if someone ever got into that state then surely don't have the healthy concern about data that should have in the first place) then make a copy of the damaged database before you run emergency mode repair.
as its a one-way operation, you cannot wrap it in an explicit user-transaction.
it's the only repair option available in emergency mode - if you try to use REPAIR_REBUILD then it won't work.


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

Points of Interest

You will be happy that your database is still in workable condition as well as the application:)

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Suvendu Banik


Member
Love to code
Occupation: Program Manager
Location: India India

Other popular SQL Reporting Services articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 24 of 24 (Total in Forum: 24) (Refresh)FirstPrevNext
QuestionThis doesn't work on system databases Pinmembersrulyt2:55 22 Jun '09  
GeneralSaved me too. PinmemberShai Bar-Lev23:15 29 Apr '09  
GeneralWorked for me. Pinmemberteza5915:08 18 Feb '09  
GeneralTHANKS!!!! Pinmemberadmlange0:16 18 Feb '09  
GeneralThank-you very much! PinmemberMarkCorsi6:38 9 Jan '09  
GeneralThanks, I owe you one big time! Pinmembersrulyt23:50 16 Nov '08  
QuestionDatabase Suspect Error Pinmembersujithkumarsl0:00 10 Nov '08  
GeneralThank you!!! PinmemberLuis C. Lopez8:50 3 Nov '08  
GeneralYou are a god amongst children PinmemberKosher16:16 18 Sep '08  
GeneralFixed my problem PinmembereNocNRoll9:01 17 Jun '08  
GeneralRe: Fixed my problem PinmemberSuvendu Banik0:58 23 Jun '08  
GeneralAnother success story! PinmemberKent Rothrock7:43 15 Jun '08  
Generalrestore suspect database in SQL-2000 Pinmembersqlbie7:38 2 Jun '08  
GeneralRe: restore suspect database in SQL-2000 PinmemberSuvendu Banik18:53 2 Jun '08  
GeneralIt worked for me. PinmemberKenThompson5:16 20 May '08  
GeneralRe: It worked for me. PinmemberSuvendu Banik18:55 2 Jun '08  
GeneralWhy? Pinmemberdragoshilbert22:18 17 Sep '07  
GeneralRe: Why? PinmemberMember 353052520:17 12 Apr '08  
GeneralREPAIR_ALLOW_DATA_LOSS option Pinmemberchopeen2:33 13 Sep '07  
GeneralRe: REPAIR_ALLOW_DATA_LOSS option PinmemberSuvendu Banik4:36 13 Sep '07  
GeneralRe: REPAIR_ALLOW_DATA_LOSS option Pinmemberchopeen4:52 13 Sep '07  
AnswerRe: REPAIR_ALLOW_DATA_LOSS option PinmemberSuvendu Banik19:12 13 Sep '07  
GeneralRe: REPAIR_ALLOW_DATA_LOSS option Pinmembereyad al akhras22:51 15 Sep '07  
QuestionRe: REPAIR_ALLOW_DATA_LOSS option PinmemberGaneshtal6:16 4 Aug '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 13 Sep 2007
Editor:
Copyright 2007 by Suvendu Banik
Everything else Copyright © CodeProject, 1999-2009
Web10 | Advertise on the Code Project