-
Viorel 94,761 Reputation points
2021-03-05T09:52:14.707+00:00 Try a modified statement:
insert into TblDest(ID, MasterID) select s.ID, s.[Master ID] from TblSource s where not exists (select * from TblDest where id = s.ID) and exists (select * from TblMaster where id = s.[Master ID])
Hi @Y a h y a ,
This error message indicates that the value you are trying to insert has a duplicate primary key.You may be using the wrong column as the primary key. The value of the primary key column must be unique and cannot appear multiple times.
You can try to create a composite primary key.Please refer to:
Create Foreign Key Relationships
If this does not solve your problem, please share us your table structure (CREATE TABLE …) and some sample data(INSERT INTO …). So that we’ll get a right direction and make some test.
Regards
Echo
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.