0

I am trying to upgrade from a server running SqlServer2005 (no service packs) to a server running SqlServer2005 service pack 3.

I am trying to copy the databases from one to another by doing a backup on one, then a restore on the other.

I am using ssms.

When I try to restore a backup of, call it DbName, created on the first server, onto the second server (I created a db DbName on the second server) I get the error message:

backup set holds a backup of a database other than the existing 'DbName' database

What's going on here and how do I fix it?

1
  • The "Backup and Restore databases" topic covers a very, very large problem set. Can you provide more detailed information about how you created the backups and how you attempted to restore them? The more detail (down to files, drives, and folders), the better. Commented Jun 17, 2010 at 16:35

1 Answer 1

3

If you created a database named DbName and you are trying to apply a backup of a different database (also named DbName) from the first server, then you will get the error that you are trying to back up a different database. This prevents mistakes where you would accidentally replace a database with the the wrong backup content.

There are two solutions, both trivial:

  • use the WITH REPLACE option of the RESTORE command, so that it replaces the database content with the different database backup set:

    Specifies that SQL Server should create the specified database and its related files even if another database already exists with the same name. In such a case, the existing database is deleted.

  • explicitly drop the existing database before the RESTORE operation.

SSMS has a special wizard that does that: right click on database, Tasks/Copy Database... but I much rather do it manually with straight T-SQL commands.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.