5,693,062 members and growing! (20,295 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, SQL Server, DBA, Dev

Posted: 4 Sep 2007
Updated: 13 Sep 2007
Views: 32,088
Bookmarked: 15 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
19 votes for this Article.
Popularity: 4.41 Rating: 3.45 out of 5
5 votes, 26.3%
1
0 votes, 0.0%
2
0 votes, 0.0%
3
3 votes, 15.8%
4
11 votes, 57.9%
5
Note: This is an unedited contribution. If this article is inappropriate, needs attention or copies someone else's work without reference then please Report This Article

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


Love to code
Occupation: Web Developer
Location: India India

Other popular SQL Reporting Services articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 19 of 19 (Total in Forum: 19) (Refresh)FirstPrevNext
GeneralThanks, I owe you one big time!membersrulyt23:50 16 Nov '08  
QuestionDatabase Suspect Errormembersujithkumarsl0:00 10 Nov '08  
GeneralThank you!!!memberLuis C. Lopez8:50 3 Nov '08  
GeneralYou are a god amongst childrenmemberKosher16:16 18 Sep '08  
GeneralFixed my problemmembereNocNRoll9:01 17 Jun '08  
GeneralRe: Fixed my problemmemberSuvendu Banik0:58 23 Jun '08  
GeneralAnother success story!memberKent Rothrock7:43 15 Jun '08  
Generalrestore suspect database in SQL-2000membersqlbie7:38 2 Jun '08  
GeneralRe: restore suspect database in SQL-2000memberSuvendu Banik18:53 2 Jun '08  
GeneralIt worked for me.memberKenThompson5:16 20 May '08  
GeneralRe: It worked for me.memberSuvendu Banik18:55 2 Jun '08  
GeneralWhy?memberdragoshilbert22:18 17 Sep '07  
GeneralRe: Why?memberMember 353052520:17 12 Apr '08  
GeneralREPAIR_ALLOW_DATA_LOSS optionmemberchopeen2:33 13 Sep '07  
GeneralRe: REPAIR_ALLOW_DATA_LOSS optionmemberSuvendu Banik4:36 13 Sep '07  
GeneralRe: REPAIR_ALLOW_DATA_LOSS optionmemberchopeen4:52 13 Sep '07  
AnswerRe: REPAIR_ALLOW_DATA_LOSS optionmemberSuvendu Banik19:12 13 Sep '07  
GeneralRe: REPAIR_ALLOW_DATA_LOSS optionmembereyad al akhras22:51 15 Sep '07  
QuestionRe: REPAIR_ALLOW_DATA_LOSS optionmemberGaneshtal6: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-2008
Web18 | Advertise on the Code Project