Hi, i am trying to do a sql upsert but am having some issues, i have two tables which i need to match two columns supp_id and manf_part_no here is my SQL USE [MyDatabase]GOmerge into products as Targetusing tempproduct as Sourceon Target.supp_id=Source.supp_id AND Target.manf_part_no=Source.manf_part_nowhen matched then update set Target.avail_qty=Source.avail_qty,Target.cost_price = Source.cost_pricewhen not matched theninsert (avail_qty, cost_price, manf_part_no, supp_id) values (Source.avail_qty,Source.cost_price,Source.manf_part_no, Source.supp_id);
do you know why this wont work i get the following error: Msg 8672, Level 16, State 1, Line 1The MERGE statement attempted to UPDATE or DELETE the same row more than once. This happens when a target row matches more than one source row. A MERGE statement cannot UPDATE/DELETE the same row of the target table multiple times. Refine the ON clause to ensure a target row matches at most one source row, or use the GROUP BY clause to group the source rows.it is really bugging me now and i dont know sql well enough to fix this myself ThanksSteve