4 Comments on “Week 3 – Corruption Challenge – The Winning Solution

  1. This was my plan as well but I couldn’t get it to work. When I went to set the database back online with the original LDF (SQL statement #3), I got this error:

    One or more files do not match the primary file of the database. If you are attempting to attach a database, retry the operation with the correct files. If this is an existing database, the file may be corrupted and should be restored from a backup.
    Log file ‘R:\SQLLogs\CorruptionChallenge3_log.LDF’ does not match the primary file. It may be from a different database or the log may have been rebuilt previously.

    What am I missing?

    • Dave,
      If you replace just the CorruptionChallenge3_log.LDF file you will get the message you mentioned. If you delete the CorruptionChallenge3.MDF file you get a totally different message, however with that MDF gone, the LDF loads enough so that you can run the tail of the log backup.

      -Steve

  2. Thanks for the challenge and the solution.
    To get the solution by myself is out of my knowledge at this point but I do enjoy working through the given solutions.
    What tripped me up when running the above solution is when the database was put back ONLINE errors show up in the SSMS Results pane.
    This made me think something was not right and second guess myself because there was no indication that anything was actually ONLINE.
    I suppose my brain was thinking “how can a database come online when their is no .mdf” so was I really meant to remove it?

    Although a refresh in Object Explorer and the ability to run further scripts did prove otherwise but not after a bit of confusion.

    I got this message:
    Msg 5120, Level 16, State 101, Line 1
    Unable to open the physical file “C:\CorruptionChallenge3\sqlfiles\CorruptionChallenge3.mdf”. Operating system error 2: “2(failed to retrieve text for this error. Reason: 15105)”.
    Msg 945, Level 14, State 2, Line 1
    Database ‘CorruptionChallenge3’ cannot be opened due to inaccessible files or insufficient memory or disk space. See the SQL Server errorlog for details.
    Msg 5069, Level 16, State 1, Line 1
    ALTER DATABASE statement failed.

    thanks again.

Leave a Reply

Your email address will not be published. Required fields are marked *

*