Hello all,
Looking at the query below I should not be inserting any rows into table1 where the an_seq field already exist.
The results are consist with the select query in terms of I only retrieve rows from table2 that current do not exist on table1 but when I try to insert the new rows into table1 the error appears. Thank.
Server: Msg 2627, Level 14, State 2, Line 1
Violation of UNIQUE KEY constraint 'IX_arc_tblxCSA_AgencyName_1'. Cannot insert duplicate key in object 'arc_tblxCSA_AgencyName'.
The statement has been terminated.
Insert into arc_tblxCSA_AgencyName
(an_Seq
,an_OrderingName
,an_AgencyName
,an_xorgSeq
,an_Inactive_DtTm
,an_LastUpdated_DtTm
,an_LastUpdated_By
)
Select an_Seq
,an_OrderingName
,an_AgencyName
,an_xorgSeq
,an_Inactive_DtTm
,an_LastUpdated_DtTm
,an_LastUpdated_By
From dbo.tblxCSA_AgencyName an
Where an.an_Seq NOT IN (Select a.an_Seq From arc_tblxCSA_AgencyName a)
Looking at the query below I should not be inserting any rows into table1 where the an_seq field already exist.
The results are consist with the select query in terms of I only retrieve rows from table2 that current do not exist on table1 but when I try to insert the new rows into table1 the error appears. Thank.
Server: Msg 2627, Level 14, State 2, Line 1
Violation of UNIQUE KEY constraint 'IX_arc_tblxCSA_AgencyName_1'. Cannot insert duplicate key in object 'arc_tblxCSA_AgencyName'.
The statement has been terminated.
Insert into arc_tblxCSA_AgencyName
(an_Seq
,an_OrderingName
,an_AgencyName
,an_xorgSeq
,an_Inactive_DtTm
,an_LastUpdated_DtTm
,an_LastUpdated_By
)
Select an_Seq
,an_OrderingName
,an_AgencyName
,an_xorgSeq
,an_Inactive_DtTm
,an_LastUpdated_DtTm
,an_LastUpdated_By
From dbo.tblxCSA_AgencyName an
Where an.an_Seq NOT IN (Select a.an_Seq From arc_tblxCSA_AgencyName a)