Recover Data File - MDF

  • Hi Everybody,

    One of my sql server 2005 database file (mdf) has corrupted and do not have back up of the database. but there is no problem in log file it seems. Please let me know the steps how do to recover the data file(mdf) with data base log file without any third party tool.

    Thanks in Advance.

  • Restore from a vaild backup, provided you have one?

    -- You can't be late until you show up.

  • tosscrosby-60625 (1/4/2010)


    Restore from a vaild backup, provided you have one?

    No .... i do not have back up of the database.

  • Sorry to say that you are basically screwed since you have no backups. Your only option is to run DBCC CHECKDB or CHECKTABLE with one of the repair options, probably REPAIR_ALLOW_DATA_LOSS which does exactly what you it says, it fixes the corruption, but you will most likely lose data. Check out Paul Randal's blog[/url] and look at the CHECKDB and Corruption tags.

  • And I was actually questioned about why I would bother posting today's editorial[/url].

    Why aren't you taking backups of the system?

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Why on earth is there no backup?

    Please run this and post the full and complete output.

    DBCC CHECKDB (<Database Name>) WITH NO_INFOMSGS, ALL_ERRORMSGS

    Without a database backup, the database cannot be recovered from the log file alone. The log file does not necessarily contain the record of all changes made to the DB, especially if the DB is in simple recovery or there has never been a backup made.

    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
  • Jack Corbett (1/4/2010)


    Sorry to say that you are basically screwed since you have no backups. Your only option is to run DBCC CHECKDB or CHECKTABLE with one of the repair options, probably REPAIR_ALLOW_DATA_LOSS which does exactly what you it says, it fixes the corruption, but you will most likely lose data. Check out Paul Randal's blog[/url] and look at the CHECKDB and Corruption tags.

    After attaching the user databases in the server, i will apply the some data patches and fixes application related, after completing this process only i will take the backup of the database.But unfortunately after completing this data patches and fixes database got corrupted.

  • And previous backups? You know, the ones you've been taking on a daily or weekly basis since you became responsible for this 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
  • Those steps 'should not' corrupt the database.

    Can you post the output from running CHECKDB ?

  • sudhakara (1/4/2010)


    Jack Corbett (1/4/2010)


    Sorry to say that you are basically screwed since you have no backups. Your only option is to run DBCC CHECKDB or CHECKTABLE with one of the repair options, probably REPAIR_ALLOW_DATA_LOSS which does exactly what you it says, it fixes the corruption, but you will most likely lose data. Check out Paul Randal's blog[/url] and look at the CHECKDB and Corruption tags.

    After attaching the user databases in the server, i will apply the some data patches and fixes application related, after completing this process only i will take the backup of the database.But unfortunately after completing this data patches and fixes database got corrupted.

    Take a backup before, take a backup after, heck, depending on how extensive the number of changes you're performing, take a backup in the middle. If you're mucking with production data, it's difficult to be overly paranoid.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Those steps 'should not' corrupt the database.

    Can you post the output from running CHECKDB ?

    It is hard to say since none of us know the entire situation involved, but first guess I would have to agree with this assessment. What errors does DBCC CHECKDB come back with?

    Joie Andrew
    "Since 1982"

  • Grant Fritchey (1/4/2010)


    sudhakara (1/4/2010)


    Jack Corbett (1/4/2010)


    Sorry to say that you are basically screwed since you have no backups. Your only option is to run DBCC CHECKDB or CHECKTABLE with one of the repair options, probably REPAIR_ALLOW_DATA_LOSS which does exactly what you it says, it fixes the corruption, but you will most likely lose data. Check out Paul Randal's blog[/url] and look at the CHECKDB and Corruption tags.

    After attaching the user databases in the server, i will apply the some data patches and fixes application related, after completing this process only i will take the backup of the database.But unfortunately after completing this data patches and fixes database got corrupted.

    Take a backup before, take a backup after, heck, depending on how extensive the number of changes you're performing, take a backup in the middle. If you're mucking with production data, it's difficult to be overly paranoid.

    In agreement with Grant - It is better to be overly paranoid, than ill-prepared.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • Are your other databases backed up ?

    This might help show holes in your backup strategy:

    http://www.mssqltips.com/tip.asp?tip=1601

  • Do you have old .mdf and .ldf files(not of the day when DB got corrupted)? you might have taken file backup on some storage.... so get it and save it some where on this server.

    If yes, just delete the current .mdf and .ldf as the DB is any which ways useless now.

    attach the old .mdf and .ldf files and see if that works.... (as the chances are very less).... if not then I'm sorry to say that the DB is gone now.....

    Rgds,
    Pankaj

  • pankaj.baluni (1/5/2010)


    if not then I'm sorry to say that the DB is gone now.....

    That is not necessarily true. There are ways to repair a SQL database with varying amounts of data loss. Until they have been tried you cannot say that the DB is gone. Recommending to delete the mdf without being 1000% sure that it is completely irreparable is very poor advice.

    I'm still waiting for the output of CheckDB to see exactly what's wrong. Sudhakara, can you run the CheckDB statement I gave you above and post the results?

    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

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

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