我正在编写一条 SQL 语句来从临时表中更新 SQL 中的表。我不断收到此错误消息:Cannot insert duplicate key row in object with unique index 'SAXXIRPT'
。
这是我的更新声明:
Update dbo.sat_ser_rpt_itm
SET itm_key_cd = n.itm_key_cd,
itm_typ_cd = n.itm_typ_cd,
ser_id = n.ser_id ,
as_of_dt = n.as_of_dt,
ocrn_nr = n.ocrn_nr ,
id_rssd = n.id_rssd,
ocrn_day_txt = n.ocrn_day_txt ,
ocrn_dt = n.ocrn_dt ,
hol_flg = n.hol_flg ,
ocrn_val_nr = n.ocrn_val_nr
from #LookupTable n
on sat_ser_rpt_itm.id_rssd = n.id_rssd
AND sat_ser_rpt_itm.as_of_dt = n.as_of_dt
AND sat_ser_rpt_itm.ser_id = n.ser_id
and sat_ser_rpt_itm.itm_typ_cd = n.itm_typ_cd
and sat_ser_rpt_itm.ocrn_nr = n.ocrn_nr
where t.id_rssd is not null and t.as_of_dt is not null and t.ser_id is not null and t.itm_typ_cd is not null and t.ocrn_nr is not null
这些是我的索引(聚集):
id_rssd, as_of_dt, ser_id, itm_key_cd and ocrn_nr
是什么导致此错误消息?