72

I have a .bak file, and I want to use this file to recreate the database in a fresh install of SQL Server 2008 Management Studio.

Can someone point me in the right direction on how this can be done?

I have tried:

  1. right click on the Databases container within object explorer

  2. from context menu select Restore database

  3. Specify To Database as either a new or existing database

  4. Specify Source for restore as from device

  5. Select Backup media as File

  6. Click the Add button and browse to the location of the BAK file

but I am getting error that

Restore failed for Server 'MyServer-PC'. (Microsoft.SqlServer.SmoExtended)

ADDITIONAL INFORMATION:

System.Data.SqlClient.SqlError: The backup set holds a backup of a database other than the existing 'invent' database. (Microsoft.SqlServer.Smo)

Ashok
  • 1,868
  • 6
  • 36
  • 70

5 Answers5

110

There is a step by step explanation (with pictures) available @ Restore DataBase

  1. Click Start, select All Programs, click Microsoft SQL Server 2008 and select SQL Server Management Studio.
    This will bring up the Connect to Server dialog box.
    Ensure that the Server name YourServerName and that Authentication is set to Windows Authentication.
    Click Connect.

  2. On the right, right-click Databases and select Restore Database.
    This will bring up the Restore Database window.

  3. On the Restore Database screen, select the From Device radio button and click the "..." box.
    This will bring up the Specify Backup screen.

  4. On the Specify Backup screen, click Add.
    This will bring up the Locate Backup File.

  5. Select the DBBackup folder and chose your BackUp File(s).

  6. On the Restore Database screen, under Select the backup sets to restore: place a check in the Restore box, next to your data and in the drop-down next to To database: select DbName.

  7. You're done.

BCdotWEB
  • 1,009
  • 1
  • 14
  • 35
Al-3sli
  • 2,161
  • 2
  • 15
  • 19
  • 3
    This was the right thing to do for me... except that I wasted some time until a workmate told me that the actual `.bak` file to be loaded **must** be in the `C:\Program Files\Microsoft SQL Server\MSSQL.15.SQLEXPRESS\MSSQL\Backup` folder. Only then I was able to get your step 5 done. Just saying, in case somebody else gets stucked in there. Thanks! – José L. Patiño Jun 29 '20 at 16:47
58

To do this via TSQL (ssms query window or sqlcmd.exe) just run:

RESTORE DATABASE MyDatabase FROM DISK='c:\backups\MyDataBase1.bak'

To do it via GUI - open SSMS, right click on Databases and follow the steps below

enter image description here enter image description here

viggity
  • 15,039
  • 7
  • 88
  • 96
  • A couple of comments on the RESTORE command option: a. Do this from the master database. b. Note the SINGLE QUOTE for the file name is super important - double quotes have a different meaning in SQL Server Management Studio. Sigh. c. If you are restoring from a different version of the database engine (e.g. SQL 2017 -> SQL 2019) you will need to manually create the target directories and explicitly give permissions to them. Double sigh. (see https://stackoverflow.com/questions/36602930/) – Mike Kelly Feb 22 '22 at 22:45
7

Using management studio the procedure can be done as follows

  1. right click on the Databases container within object explorer
  2. from context menu select Restore database
  3. Specify To Database as either a new or existing database
  4. Specify Source for restore as from device
  5. Select Backup media as File
  6. Click the Add button and browse to the location of the BAK file

refer

You'll need to specify the WITH REPLACE option to overwrite the existing adventure_second database with a backup taken from a different database.

Click option menu and tick Overwrite the existing database(With replace)

Reference

Nagaraj S
  • 13,316
  • 6
  • 32
  • 53
1

I had the same error. What worked for me is when you go for the SMSS GUI option, look at General, Files in Options settings. After I did that (replace DB, set location) all went well.

buczek
  • 2,011
  • 7
  • 29
  • 40
DIKKEHENK
  • 11
  • 1
0

Restoring a Database from Backup

sql-server-->connect to instance-->Databases-->right-click on databases-->Restore
            DataBase..-->Device-->Add-->choose the path_filename(.bak)-->click OK
Amit
  • 15,217
  • 8
  • 46
  • 68
vhadalgi
  • 7,027
  • 6
  • 38
  • 67