Database Corruption problems

  • We had a server reboot the other night and it seams to have corrupted several files. I have a database in SQL Express that is corrupt and one in regular SQL that was labeled suspect. I found this on a web site for fixing suspect DB's.

    ALTER DATABASE koochdata SET EMERGENCY

    DBCC checkdb('koochdata')

    ALTER DATABASE koochdata SET SINGLE_USER WITH ROLLBACK IMMEDIATE

    DBCC CheckDB ('koochdata', REPAIR_ALLOW_DATA_LOSS)

    ALTER DATABASE koochdata SET MULTI_USER

    When I issue these one at a time I can see in the log files that the DB is changing status but when I run the dbcc commands I get this result.

    Msg 922, Level 14, State 1, Line 1

    Database 'KoochData' is being recovered. Waiting until recovery is finished.

    Query completed with errors

    I haven't been able to find msg 922 anywhere. Is there a reason that dbcc doesn't want to work? It didn't leave a message in the log file just the changes in the DB status.

    Also. Can I use the same procedure in Sqlserver express?

    Thank you in advance.

    Quinn McCarthy

  • Also

    When I right click on the DB and go to properties I get the same 922 message however it says it is in recovery mode. When I look at sys.databases I see the state is 3 and state_desc is recovery pending. Do these have to be changed to be able to do DBCC?

    Thanks again

    Quinn

  • Do you have a backup?

    Can you look at the error log and see if there's any entry there that indicates why the database is in recovery-pending?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Gail

    We found out yesterday that the backup of both the sql and sql express DB's had not been working. We are not exactly sure why.

    There isn't anything in either log files that stands out as making it go into recovery mode.

    Here is the part where it finds a problem starting up the DB.

    2008-06-23 08:29:13.21 spid55 Starting up database 'KoochData'.

    2008-06-23 08:29:13.21 spid55 Error: 9003, Severity: 20, State: 1.

    2008-06-23 08:29:13.21 spid55 The log scan number (145:4893:239) passed to log scan in database 'KoochData' is not valid. This error may indicate data corruption or that the log file (.ldf) does not match the data file (.mdf). If this error occurred during replication, re-create the publication. Otherwise, restore from backup if the problem results in a failure during startup.

    2008-06-23 08:29:13.21 spid55 Error: 3414, Severity: 21, State: 1.

    2008-06-23 08:29:13.21 spid55 An error occurred during recovery, preventing the database 'KoochData' (database ID 8) from restarting. Diagnose the recovery errors and fix them, or restore from a known good backup. If errors are not corrected or expected, contact Technical Support.

    Before that was a bunch of messages that show the state of the DB. Like emergency mode, single user mode, and multi user mode. That was from me exucuting the code from the first thread.

    I wanted to get it out of suspect mode and read online the way to do that was to change to emergency mode. I was trying to get to a point where I could run dbcc.

    Do you know of any good recovery software?

    Thanks

    Quinn

  • Do you have replication on either of these databases?

    Is there any chance that someone has been messing with the files?

    Very important, do you have a backup?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • None at all Gail.

    Quinn

  • I'm not sure how to recover from that problem without loosing some data.

    If you try to set the database into emergency mode, can you view the tables? Can you select data from them?

    Don't try running repair. It won't help in this scenario.

    How big is the database?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Gail,

    I appreciate all of your help.

    I think I am going to call it a loss. THe DB is a holding area for as400 data for use with our GIS system and I think it can be recreated after I talk to the as400 people.

    Thanks Again

    Quinn

  • Excellent.

    If you find there is data you can't recreate, post again here and I'll try and help you salvage as much as possible from the DB.

    You may also want to do some checks on the hardware on that server, specifically on the storage system, to see if you can find a cause for the corruption.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Personally I think this is a time to call Microsoft Product Support.

    Best,
    Kevin G. Boles
    SQL Server Consultant
    SQL MVP 2007-2012
    TheSQLGuru on googles mail service

  • PSS won't be able to do anything different.

    One of the steps of emergency mode repair is to try forcing recovery with the equivalent of WITH CONTINUE_AFTER_ERROR - looks like in this case it's caused the recovery code to hang. This is only the second time I've seen it fail since I wrote it - but it's a last ditch effort when everything's corrupt and there's no backup so I'm not surprised there are some cases where even it can't 'fix' things.

    Your only options at this point are:

    1 EMERGENCY mode and extract into a new database

    2 delete the log file and run repair

    #2 should only be attempted if you're comfortable. It's really ok as the log and database are corrupt anyway, so you're not losing anything by manually throwing away the transaction log. Follow these steps:

    - shutdown

    - make a complete copy of all database files on separate storage (in case you want to go back to your current state)

    - delete the log file from the database

    - start up

    - put the database in emergency mode

    - run repair - this won't try to run recovery this time, but will simply create a new log file and then run a full repair

    Your data will be transactionally inconsistent and you'll have lost some but the database will be usable by SQL Server (not necessarily your application).

    Do all of this at your own risk. The most important thing is to make a copy of all the database files before you start so you can go back to your current state.

    Thanks

    Paul Randal
    CEO, SQLskills.com: Check out SQLskills online training!
    Blog:www.SQLskills.com/blogs/paul Twitter: @PaulRandal
    SQL MVP, Microsoft RD, Contributing Editor of TechNet Magazine
    Author of DBCC CHECKDB/repair (and other Storage Engine) code of SQL Server 2005

  • Thanks Paul.

    I had read about deleting the log file on another site. I just didn't have the guts to try it. Maybe I will give it a whirl. At this point I have nothing to lose.

    Thanks

    Quinn

  • Hey Paul, If you won't beat your own drum I will

    GO HERE !!!!

    http://www.microsoft.com/emea/teched2008/itpro/tv/default.aspx?vid=78.

    LEARN

    Enjoy!

    I did and have discovered the Power of DBCC page and Checkdb, and directly aided me recovering a large Database faster than a 4 hour restore.

    Also I'd suggest you hunt up a copy of Rodney Landrum's eBook "SQL Server Tacklebox" especially the last chapter.

    CodeOn

    😛

  • Malcolm Daughtree (3/3/2010)


    Hey Paul, If you won't beat your own drum I will

    GO HERE !!!!

    http://www.microsoft.com/emea/teched2008/itpro/tv/default.aspx?vid=78.

    LEARN

    Enjoy!

    I did and have discovered the Power of DBCC page and Checkdb, and directly aided me recovering a large Database faster than a 4 hour restore.

    Also I'd suggest you hunt up a copy of Rodney Landrum's eBook "SQL Server Tacklebox" especially the last chapter.

    CodeOn

    😛

    Thanks Malcolm for pointing to a wonderful webcast of Paul explaining details of corruption with practical demos. I saw the whole and learned a lot. 🙂

    Sometimes just reading forums regularly helps to gain knowledge !

    \\K

    ______________________________________________________________________________________________________________________________________________________________________________________
    HTH !
    Kin
    MCTS : 2005, 2008
    Active SQL Server Community Contributor 🙂

  • Sometimes just reading forums regularly helps to gain knowledge !

    Actually you didn't need to read this forum to gain knowledge. That stuff you watched has been on the web for a long time now. 😀

    Best,
    Kevin G. Boles
    SQL Server Consultant
    SQL MVP 2007-2012
    TheSQLGuru on googles mail service

Viewing 15 posts - 1 through 15 (of 20 total)

You must be logged in to reply to this topic. Login to reply