I got a SQL server (express) database backup (.bak file) from a customer to do a test against. In the past, I just restored from my own, previously existing databases, so I never came across the issue of restoring one from a complete different machine. Using SSMS I got the following error messages
The backup set holds a backup of a database other than the existing database – or
File 'Db' cannot be restored to 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.CUSTOMER\MSSQL\DATA\Db.mdf'. Use WITH MOVE to identify a valid location for the file.
The path does not exist on my machine. After browsing the web I found out the following:
- create a new and empty database named as the one from the customer (in this case ‘Db’)
- use a script to run
RESTORE DATABASE [Db]
FROM DISK = 'c:\theDbBackup.bak'