Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL-Server: The backup set holds a backup of a database other than the existing

Tags:

sql-server

I am trying to restore a SQL Server backup file for my database, but it is throwing an error as follow:

The backup set holds a backup of a database other than the existing

My database in SQL Server 2008 and the backup file is in 2005.

What can be the problem?

like image 919
R.D. Avatar asked Apr 18 '12 07:04

R.D.


People also ask

When you get following error Error 3154 The backup set holds a backup of a database other than the existing database?

The reason behind this technical issue – SQL Database Backup Restore Error 3154: The backup set holds a backup of a database other than the existing database, is that the name of the database in which you want to restore the backup set and the database whose backup was created is the same.

What is backup set in SQL Server?

A backup set contains the backup from a single, successful backup operation. RESTORE, RESTORE FILELISTONLY, RESTORE HEADERONLY, and RESTORE VERIFYONLY statements operate on a single backup set within the media set on the specified backup device or devices. This table is stored in the msdb database.

What are the main 3 types of backups in SQL?

A backup of data in a complete database (a database backup), a partial database (a partial backup), or a set of data files or filegroups (a file backup). A backup of a database.


2 Answers

I too came across this issue.

Solution :

  • Don't create an empty database and restore the .bak file on to it.
  • Use 'Restore Database' option accessible by right clicking the "Databases" branch of the SQL Server Management Studio and provide the database name while providing the source to restore.
  • Also change the file names at "Files" if the other database still exists. Otherwise you get "The file '...' cannot be overwritten. It is being used by database 'yourFirstDb'".
like image 164
sunil_philip Avatar answered Oct 10 '22 07:10

sunil_philip


Either:

1) Use WITH REPLACE while using the RESTORE command (if using the GUI, it is found under Options -> Overwrite the existing database (WITH REPLACE)).

2) Delete the older database which is conflicting and restore again using RESTORE command.

Check the link for more details.

like image 42
Amarnath Avatar answered Oct 10 '22 07:10

Amarnath