There are 2 databases DB_Main
and DB_Backup
in SQL Server 2008.
I want to copy the data of Table1
from DB_Backup
into Table1
of DB_Main
.
The structure of all the tables in both the database is same. Both the tables in both the database have foreign key, primary key constraint.
When I try to copy data of Table1
from DB_Backup
into Table1
of DB_Main
with this query:
Insert into [DB_Main].[Table1]
Select *
from [DB_Backup].[Table1];
I get this foreign key error.
The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Table1_Table3". The conflict occurred in database "DB_Main", table "Table3", column 'RequestID'.
Please let me know any simple way to copy all the records of Table1
from DB_Backup
into Table1
of DB_Main
, without violating any constraint?
Please reply