locked
Repair Corrupted MDF & LDF Files ????

    Question

  • Hi All

    I am looking for repair tools for corrupted mdf and ldf files,

    ( These files beeing corrupted after i restore them using Easy Recovery Profissional after formatting c drive by mistake. )

    Remark : one file of my 3 databases work perfectly when i use attach database.

    Any Help will Be appreciated.

    thanks

     

    Tuesday, April 18, 2006 10:57 AM

Answers

All replies

  • What errors comes back while attaching the database ?

    HTH, Jens Suessmeyer.

    ---
    http://www.sqlserver2005.de
    ---
    Tuesday, April 18, 2006 9:20 PM
  • You can Repair MDF file using MDF Repair software

    ...
    http://www.mdfrepair.com/
    Monday, May 04, 2009 10:31 AM
  • If your mdf and ldf files gets corrupted try Stellar Phoenix SQL Database Recovery Software as it repair corrupted mdf files.

    http://www.repairmdf.com
    Tuesday, May 05, 2009 6:44 AM
  • You can take advantage of SQL database repair tool. I have used this tool and it works perfectly. I have downloaded the tool from http://www.nucleustechnologies.com/sql-recovery.html
    • Edited by Tech Tiger Tuesday, June 16, 2009 4:44 AM
    Monday, June 15, 2009 4:19 AM
  • It seems that this tool is for Access databases only. He was talking of MDF and LDF files which is SQL Server and another storage format which I doubt is covered in the Access repair kit.

    -Jens
    Jens K. Suessmeyer http://blogs.msdn.com/Jenss
    Monday, June 15, 2009 5:47 AM
  • so did you got the solution if you got plesae let me know i try stellar but that software is much much expensive and as i cannot afford it so i leaved that solution so could you help me???????????? Regards Zeeshan
    Monday, August 03, 2009 10:50 AM
  • Hi,
    i was 6 days ago my computer formatted, i'm hungry because, I dont backup SQL 2005 database files. Thanks to Ontrack easy recovery 6.1, repaired sql databases but i dont attach this files. Sql server error : "xxx.mdf is not a primary database file (Microsoft Sql Server Error : 5171)

    Can you help me, please?

    Thank you.

    Wednesday, June 23, 2010 7:28 AM
  • Hi,

    Try this....

    shutdown sql
    move the current database file or rename it
    restart sql server
    create a new database of the same name and log file and location as the old
    database and log file
    get rid of the old database.
    you may be able to right click delete it in this situation or used
    sp_removedb



    stop sql

    rename the new databases.mdf or delete it if you don't have enough space -
    do not touch the .ldf

    move back in the old database .mdf file or rename it back again

    restart sql server

    it should come up suspect
    --------------------------------
    1. From a query window, set the status so that you can update the system
    tables by running the following query:
    use Master
    go
    sp_configure "allow", 1
    go
    reconfigure with override
    go

    2. Then set the status of the DB that is giving you the problem (XXXXX) into
    Emergency Mode by running the following query:

    update sysdatabases set status = 32768 where name = '<DBName>'
    go
    checkpoint
    go
    shutdown with nowait
    go

    3. Go into the data directory (MSSQL7\DATA) and rename the log file
    associated
    the DB in question (XXXX.ldf) to some
    temporary name, such as XXXX.TMP.

    4. Exit the query window.
    5. Then start up SQL Server from a DOS command window by issuing:
    sqlservr -c -T3608 -T4022.
    6. Bring up another query window and verify that the DB is in emergency mode
    by issuing:
    select Name, Status from Sysdatabases where name = '<DB_Name>'

    7. Verify that the status is 32768. If it is, then issue the query:
    dbcc traceon(3604)
    dbcc rebuild_log('<DB_Name>','<log_filename>') <--- You will need
    the quotation marks
    REBUILD_LOG should take less than 5 minutes even on a very large
    database. It should complete with the message
    DBCC execution completed
    8. Take the database out of bypass recovery mode by issuing the command
    update sysdatabases set status = 0 where name = '<DBName>'
    9. Exit the query window and then shutdown (Ctrl-C in the DOS window) and
    restart SQL server. Verify the status of the
    database by running DBCC NEWALLOC and DBCC CHECKDB on the database.


    Srikanth.kls
    Thursday, June 24, 2010 5:27 AM
  • Agree with Davidpoul, You can try updated version of stellar sql database recovery software which can repair mdf as well as ndf files of sql server database.

    Thanks

    Tuesday, October 19, 2010 5:34 AM
  • Hi,

    Try this....

    shutdown sql
    move the current database file or rename it
    restart sql server
    create a new database of the same name and log file and location as the old
    database and log file
    get rid of the old database.
    you may be able to right click delete it in this situation or used
    sp_removedb



    stop sql

    rename the new databases.mdf or delete it if you don't have enough space -
    do not touch the .ldf

    move back in the old database .mdf file or rename it back again

    restart sql server

    it should come up suspect
    --------------------------------
    1. From a query window, set the status so that you can update the system
    tables by running the following query:
    use Master
    go
    sp_configure "allow", 1
    go
    reconfigure with override
    go

    2. Then set the status of the DB that is giving you the problem (XXXXX) into
    Emergency Mode by running the following query:

    update sysdatabases set status = 32768 where name = '<DBName>'
    go
    checkpoint
    go
    shutdown with nowait
    go

    3. Go into the data directory (MSSQL7\DATA) and rename the log file
    associated
    the DB in question (XXXX.ldf) to some
    temporary name, such as XXXX.TMP.

    4. Exit the query window.
    5. Then start up SQL Server from a DOS command window by issuing:
    sqlservr -c -T3608 -T4022.
    6. Bring up another query window and verify that the DB is in emergency mode
    by issuing:
    select Name, Status from Sysdatabases where name = '<DB_Name>'

    7. Verify that the status is 32768. If it is, then issue the query:
    dbcc traceon(3604)
    dbcc rebuild_log('<DB_Name>','<log_filename>') <--- You will need
    the quotation marks
    REBUILD_LOG should take less than 5 minutes even on a very large
    database. It should complete with the message
    DBCC execution completed
    8. Take the database out of bypass recovery mode by issuing the command
    update sysdatabases set status = 0 where name = '<DBName>'
    9. Exit the query window and then shutdown (Ctrl-C in the DOS window) and
    restart SQL server. Verify the status of the
    database by running DBCC NEWALLOC and DBCC CHECKDB on the database.


    Srikanth.kls

     

    This would NOT work in SQL 2005.You can't update system catalogs. also dbcc rebuild_log has been removed from SQL 2005.


    Balmukund Lakhani | Please mark solved if I've answered your question
    --------------------------------------------------------------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
    --------------------------------------------------------------------------------
    My Blog: http://blogs.msdn.com/blakhani
    Team Blog: http://blogs.msdn.com/sqlserverfaq
    Tuesday, October 19, 2010 6:05 AM
  • I have also heard about another .mdf repair utility
    Thursday, March 17, 2011 3:17 PM
  • May be while formatting your c drive your saved data is corrupted but you can repair your corrupt mdf and ldf files with a unique tool.

    I have repaired my mdf files successfully using this tool and restored that on sql server. You can get more information from this blog http://www.repairsqlserver.n.nu/ 

    Friday, April 27, 2012 10:19 AM
  • ZahranyM,

    Do you have backups?

    Friday, April 27, 2012 7:21 PM
  • you can get some useful information from : Repair MDF File it will help you to recover MDF files from corruption cases.
    Tuesday, May 15, 2012 11:59 AM
  • This was helpfull for me, I just used something different way to  rebuild log and mdf on sql2000:

    1a. Enterpirse Manager

    shutdown sql
    move the current database file or rename it
    restart sql server
    create a new database of the same name and log file and location as the old 
    database and log file
    get rid of the old database.
    stop sql

    rename the new databases.mdf or delete it if you don't have enough space - 
    do not touch the .ldf

    move back in the old database .mdf file or rename it back again

    restart sql server


    -- LISTING 1: Undocumented DBCC Command REBUILD_LOG
    EXEC sp_configure 'allow updates', 1
    RECONFIGURE WITH OVERRIDE
    GO

    BEGIN TRAN

    UPDATE master..sysdatabases
    SET status = status | 32768
    WHERE name = '<DatabaseName>'

    IF @@ROWCOUNT = 1
    BEGIN
       COMMIT TRAN
       RAISERROR('emergency mode set', 0, 1)
    END
    ELSE
    BEGIN
       ROLLBACK
       RAISERROR('unable to set emergency mode', 16, 1)
    END

    GO

    EXEC sp_configure 'allow updates', 0
    RECONFIGURE WITH OVERRIDE
    GO

    -- Restart SQL Server at this point. 

    DBCC REBUILD_LOG('<DatabaseName>','<Path to .ldf file>')
    GO

    ALTER DATABASE <DatabaseName> SET MULTI_USER
    GO

    /*Perform physical and logical integrity checks at this point.
    Bcp data out if your integrity checks demonstrate that problems exist.
    */



    Code:

    DBCC CHECKDB (<DatabaseName>)

    If you ger no errors, than your database is back.

    If you get errors, than proceed:

    Code:

    ALTER DATABASE <DatabaseName> SET SINGLE_USER



    Code:

    DBCC CHECKDB (<DatabaseName>, REPAIR_FAST)


    - try this more times...

    Code:

    DBCC CHECKDB (<DatabaseName>, REPAIR_REBUILD)


    - also more times...

    Code:

    DBCC CHECKDB (<DatabaseName>, REPAIR_ALLOW_DATA_LOSS)


    - more times, (5-6)

    Code:

    ALTER DATABASE <DatabaseName> SET MULTI_USER




    • Edited by okan5 Monday, February 11, 2013 7:30 AM
    Monday, February 11, 2013 7:29 AM
  • You can recover the mdf and ldf files of user databases and fix SQL errors by SQL Database Recovery. The database can be recovered and restored back to the SQL server after recovery.

    Monday, February 25, 2013 10:43 AM
  • can you help me recover this one. I want it

    thank  you very much


    mediafire.com
    /download/
    2a6d71einnd72dd/
    phbc.rar

    thanks.

    Friday, June 07, 2013 3:40 PM
  • Can you try the recovery tool?

    Link: http://www.sqlrecoverytool.com/

    Let us know if works for you. Thanks.


    Kalman Toth Database & OLAP Architect sqlusa.com
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

    Monday, June 10, 2013 1:10 AM
  • In the condition of SQL Server Crash You should always try to secure your important data of SQL database.I have some idea about a recovery tool which can recover corrupted data without any hassle,It is Stellar for SQL Recovery software which  is not only easy to use but its interactive and user-friendly screens makes this tool a favorite among novice computer users as well.It's also helpful for a batch file for recovered objects  and to easily save them to new database created on SQL server. You can get more details about this tool from here 

    http://www.recoverydeletedfiles.com/sql-database-recovery-software.html

    may be it help you to save sql database.

    Monday, June 17, 2013 4:08 PM
  • Repair this files thanks to repair database mdb

    http://www.repairmdb.accessrepairtoolbox.com

    Sunday, September 08, 2013 2:19 PM
  • Here is a SQL query I found here

    ALTER DATABASE test

    SET emergency

    GO

    ALTER DATABASE test

    SET single_user

    GO

    DBCC checkdb (test, repair_allow_data_loss)

    ALTER DATABASE test

    SET multi_user

    GO



    If this doesn't help then I suggest restoring from backup, using 3rd party tool like ApexSQL Recover

    Sunday, September 22, 2013 11:22 PM
  • Hi All

    I am looking for repair tools for corrupted mdf and ldf files,

    ( These files beeing corrupted after i restore them using Easy Recovery Profissional after formatting c drive by mistake. )

    Remark : one file of my 3 databases work perfectly when i use attach database.

    Any Help will Be appreciated.

    thanks

     


    '.mdf ' file of your database gets corrupted due to any internal or external error and if  .mdf file gets corrupted then it can corrupt the entire database or make it inaccessible. This file contains the structure of the database and all operations are executed on to a single .mdf file so that it can be easily got corrupted.

    How to know that .mdf file is corrupted:

    • Unable to access database or the content of the database.
    • Database not responding
    •  Any error displayed by the database.
    •  User unable to execute DML operation.
    • Database unable to execute user entries and query.

    You can recover and restore corrupted .dbf file by using Database Repair Tool, this tool can easily repair and restore your corrupt .mdf file. 


    • Edited by jackadision Monday, October 21, 2013 6:20 AM
    Monday, October 21, 2013 6:18 AM
  • Step to repair corrupt MS SQL MDF file manually. Read carefully and try to repair by yourself.
    http://exchangeserverstips.wordpress.com/2013/12/31/steps-to-repair-sql-server-mdf-file-when-dbcc-checkdb-fails/

    Thanks

    Tuesday, December 31, 2013 12:18 PM