Showing posts with label SQL Server. Show all posts
Showing posts with label SQL Server. Show all posts

SQL SERVER – FIX : Error 3154: The backup set holds a backup of a database other than the existing database

One of my friend came to me with this error just a few days ago while restoring the database:

Error 3154: The backup set holds a backup of a database other than the existing database.

Solution is very simple and not as difficult as we were thinking. He was trying to restore the database on another existing active database.

Fix/WorkAround/Solution:

1) Use WITH REPLACE while using the RESTORE command.
2) Delete the older database which is conflicting and restore again using RESTORE command.
I understand my solution is little different but I use it to fix my database issue successfully.
3) Sample Example :

RESTORE DATABASE [DB_Name]
FROM DISK = N'F:\ProdDBBackup\db_201305011837.SAFE_2.bak'
WITH REPLACE

Truncate Table with Foreign key constraint

Cannot truncate table 'table' because it is being referenced by a FOREIGN KEY constraint.

Solution for the above issue is below:
Delete from <tablename>
DBCC CHECKIDENT(
<tablename>,RESEED,0)

 
Designed and Maintained by