Pages

Wednesday, November 23, 2011

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

Wish you all a Happy Thanks Giving. Thanksgiving was real blessing this time because i got the needed rest from a tiring project. It was titring in many front because we were dealing with an accounting firm and we ought to get the project done before the end of November so they can sign off and proceed to go live. Now finally the the week of thanks giving we are done and they are merrily testing the solution. I wanted to blog this information here because it might be useful for many who are using custom database in there application solution.


We were buiilding a sharepoint solution and had a custom database for some of our custom operations. One of our developer who was new had to restore database from a backup and he got the error which he had no clue off. "System.Data.SqlClient.SqlError: The backup set holds a backup of a database other than the existing database". The error had nothing to do with him. He was trying to restore the database from the backup using SQL Server Management studio and using the restore option. There are couple of reasons why this error could come up

1. if restoring from a different version of SQL Server.
2. If  logical Name of the Database is different from the one that is backed up.

In our case it was the first option because we backed up long time ago and the developer was trying to restore it on SQL Server R2.

Following T-SQL query can be handy in fixing this. Make sure you run this query on the master and not on the database itself.


RESTORE DATABASE TestDatabase
FROM DISK = 'C:\BackupTestDatabase.bak'
WITH REPLACE

Happy Thanks Giving

http://g.co/doodle/ab23hc