Microsoft SQL Server: How to recover a suspect database

Thảo luận trong 'Góc Windows' bắt đầu bởi hautp, Thg 12 20, 2012.

  1. hautp

    hautp Well-Known Member

    Normaly you should always have backups of your databases, restoring suspected databases is not a good option, but I think at some point in time, in some situation you’ll want to do it anyway.
    So today I set up a test case for this. I mirrored one of our database servers and made it crash, badly.
    Two databases were corrupted, and went to the "suspect state".
    Microsoft SQL Server started throwing errors in our general direction like:
    Not good, but just what we wanted…
    So how would it be possible to recover these databases?
    First, set them to emergency mode, this way you will be able to retrieve control.
    In emergency mode you can actually open the database:
    Second, put them in single mode (needed for the check we will be performing):
    Then, check the database (this repair allows data-loss, since I’m sure some data will have to be lost in my scenario):
    Finally, if the check succeeded, you can re-enter multi-mode:
    And there you go, the database is restored…
    Not a best practice, but it may save some time once. So if you ever have a problem on your dedicated server database hosting, you know this might to the trick.

Chia sẻ trang này