Search code examples
sql-serverdatabase-restore

restoring original MDF file from bak file


I've got a bak file (which is a backup database file for a SQL server express 2005 mdf file) and I should obtain the MDF file so that I can work on its tables, how can I get the original MDF file from this bak file? I'm using Visual Studio 2012, is it necessary to have management studio? I've tried to restore this bak file to an empty database in another system containing Sql server express management studio 2008, but it says databases don't match, what is going wrong?


Solution

  • If you have created a blank database, to overwrite this with the backup you will need to specify the WITH REPLACE parameter.

    Also, you may have to specify the MOVE parameter to put the files into the correct locations.

    You should be able to quite easily find these options in the GUI when doing the restore, or alternatively you can script it out by using the reference here:

    How to: Restore a Database to a New Location and Name (Transact-SQL)