can I restore a database using .mdf and .ldf files?

  • I forgot to backup a database before uninstalling SQL server. Fortunately I still have a very old backup and the .mdf and .ldf files on the server. Is there any way to restore the database using the very old backup but use the .mdf and .ldf files (from today) to restore the database. I need the newest data in the database.

    Can this be done and if so, what are the steps? 

    THanks a bunch!

  • You could try to reattach the database using the .mdf and .ldf files but I cannot remember if this works with unattached databases

    Far away is close at hand in the images of elsewhere.
    Anon.

  • Hmmmm, good point. What if I restored the very old backup, with a different .mdf and .ldf files name. THen reattched it with the .mdf and .ldf files from today. Would that work?

  • Hello,

    You can restore the database with the backup file you have. Note down the drive location where you are restoring this database to. Now detach the database and overwrite the .mdf and .ldf files with the one you have. Then you attach back the database.

    Note: The restored database files and the individual files (.mdf and .ldf) should be identical in their filenames.

    Hope this helps you.

    Thanks

     


    Lucky

  • Thanks for your input everyone. I was actually able to retach the dabatbase from Enterprise manager just be right clicking and attaching. All I had to do was give the location of the .mdf file and it found the .ldf file on it's own and restore the database with it's original name. THanks for al your help.

  • Yes, By using Sql Server Enterprise Manager. Using Attach Database option.

  • You guys are life-savers. It is the holidays and all of our DBAs are out of the office. DB Instance crashed and could not repair. I ended up uninstalling and re-installing. The replies here allowed me to reattach all of the databases.

    Thanks!!!

  • u can do the restoration tasks with particular extensions and should check the file location where u have to restore

  • this was an awesome contribution

    thanks alot

  • If you have forgotten to backup database before uninstalling SQL server. Then there is very little chance to restore .mdf data using very old backup. But do not lose hope there is still a way to perform mdf repair and restore use third party tool known as SQL Repair software with this you will surely restore the deleted data.

    😛

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

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