Use database files in another database

  • Hello,

    I have a database file (mdf) and it's log file on a portable hard drive. My computer's hard drive crashed today. Due to the crash, I am trying to access the database files using my other computer.

    How do I create a database on my new machine using the existing database and log files?

    I was not able to backup the data before the disk crash, thus I only have the MDF and LOG files without any backup file.

    Please help.

    Thanks

    Rohan

  • If you have SQL Server running on your other pc, attach your harddrive to that PC and then attach the database files as normal to you pc's sql server instance.

  • Hello,

    Thank you for your response, I tried the "Attach" method but I got the below error:

    "CREATE FILE encountered operating system error 5 (Access is denied) while attempting to open"

    Can you please suggest how do I access these files?

    Thanks

  • Ah yes, if you are the admin on the computer your using, you will need to update the permissions on the database files via windows explorer > right clicking on one of the db files and selecting the permissions option.

    Navigate to the security tab and update the permissions to allow everyone access, do this for both db files, then try to reattach

  • Thank you so much for your help. I logged in as SA and attached the files. Then I logged out and logged back in as user and everything works well.

    This issue is now resolved.

Viewing 5 posts - 1 through 4 (of 4 total)

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