Attach Damaged .Mdf file

  • Hi to all,

    I am facing a greate problem!!!

    My database has been crashed but i saved the .mdf file but my .ldf file has been lost.

    Now, problem is when i attach this file it gives an error : "Could not continue scan because of some page id has been corrupted "

    and displays "Connection Broken".

    Is there any way to retrieve the data ?

     

    Regards,

    Amit Gupta.

     

     

     

     

  • There is a way to retrieve the Data but could result in Data Loss.

    I would suggest resort to LAST KNOWN GOOD BACKUP. But if there is no backup or old backup then use the following steps....

    Steps ::

    1. Create a Sample Database called TEST with as many MDF Files and LDF Files as the Corrupted one.

    2. Stop SQL Server

    3. Copy the Corrupted database MDF File onto a different location as backup. Rename the MDF file to TEST_Data.mdf.And Replace the TEST MDF File with the Corrupted Database MDF File.

    4. Restart SQL Services

    5. Database would come up in suspect.

    6. Since Log File will not be linked to the new MDF File you have to run DBCC REBUILD_LOG

    dbcc rebuild_log('dbname','New Log File NAme')

    7. Run dbcc checkdb as well.

    Consult MS Support if the above steps does not solve the problem.

     

    Also  make a copy of the MDF File before trying these out.

    SUMIT

  • Hi,

    I have already done these steps but these are not effective one for me.

    My mdf file has one or more corrupt pages, so i can't execute even a single query on it.

    If you have a solution regarding this then pls let me know about it.

    Thanks,

    Amit

     

  • If the corrupted file is the file that is holding the structure of the page files, after you bring the database from the suspect state you can try to export data out of the tables and reimport them back.

    If pages are corrupted, doesn't matter what you will do, I think that pages are lost so base on the page id you can take a look at them and see if you can leave without that data in the database, it might be some archive data, some stuff that you do not need.

  • Hi,

    pls. can you explain it in practical way.

    1) i have mdf file which is offline.

    first i have to restore it ? but i failed to restore it.

    How i can do it?.

    Then i will proceed further.

    You have any idea or tric to solve that problem

    Thanks.

    I waill wait for your opinion?

    Amit

  • Simplistically and I am not 100% sure that will work exactly as follow since I haven't test it, but hopefully it would give you some ideas.

    Create a database with the same name as the corrupted one (same mdf name file)

    stop the SQL Server

    replace the mdf

    restart SQL Server

    at this point since the mdf has problems the database would be marked as suspect

    change the database in emergency mode, here is explained how

    http://www.sqlservercentral.com/columnists/bknight/unmarksuspect.asp

    export data from the tables, delete the tables content and import the data back.

     

    If data pages are corrupted base on the result of checkdb or the error that you have on SQL Server log, Event Viewer you might be able to find the page id

    Using the pageid you can use DBCC Page to see the content of the pages with issues

    For details about using DBCC Page see Inside SQL Server 2000 - Kalen Delaney

  • Hi,

    Thanks for your valuable hints but still i am not able to restore it.

    Do you have any other way to retrieve it.

     

    Thanks

    Amit

  • Where did you got stucked?

  • Hi,

    After following all the steps. when i opened the database in Emergency Mode.

    I can not able to execute a single command overe it. It gives an error

    " Could not continue scan due to corruption of one or more pages. "

    And the command terminates.

    Please provide any solution to resolve this.

    Regards,

    Amit Gupta

     

  • Amit - I have (most fortunately) not faced anything similar but did come across a couple of good posts that may just yet provide the solution you need..see if they help any:

    repairing corrupt database #1

    corrupt database #2







    **ASCII stupid question, get a stupid ANSI !!!**

  • Even if you try to bcp or use DTS to take data out of tables, one by one?

     

    From a different point, can you afford to run

    checkdb with REPAIR_ALLOW_DATA_LOSS?

Viewing 11 posts - 1 through 10 (of 10 total)

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