这是一个BUG吗?可以怎么样处理
发生时间: 2015-10-25 02:51:44
错误编号: BOS_ExecuteNonQuery
错误信息: 不能在具有唯一索引 'IDX_STK_INVENTORY_CLUST' 的对象 'dbo.T_STK_INVENTORY' 中插入重复键的行。
语句已终止。
Sql语句:
MERGE INTO T_STK_INVENTORY IT
USING (SELECT MIN(FINVENTORYID) AS FINVENTORYID, SUM(FBASEQTY) AS FBASEQTY,SUM(FSECQTY) AS FSECQTY,
FSTOCKORGID,FKEEPERTYPEID,FKEEPERID,FOWNERTYPEID,FOWNERID,FSTOCKID,FSTOCKLOCID,FAUXPROPID,FSTOCKSTATUSID,
FLOT,FBOMID,FMTONO,FPROJECTNO,FPRODUCEDATE,FEXPIRYDATE,FBASEUNITID,FSTOCKUNITID,FMATERIALID,FSECUNITID
FROM #TM_STK_UpdateStockToTemp
GROUP BY FMATERIALID,FSTOCKORGID,FKEEPERTYPEID,FKEEPERID,FOWNERTYPEID,FOWNERID,FSTOCKID,FSTOCKLOCID,FAUXPROPID,FSTOCKSTATUSID,
FLOT,FBOMID,FMTONO,FPROJECTNO,FPRODUCEDATE,FEXPIRYDATE,FBASEUNITID,FSTOCKUNITID,FSECUNITID ) IT2
ON (IT.FID = IT2.FINVENTORYID)
WHEN MATCHED THEN
UPDATE SET IT.FBASEQTY = IT.FBASEQTY + IT2.FBASEQTY,IT.FSECQTY = IT.FSECQTY + IT2.FSECQTY
WHEN NOT MATCHED THEN
INSERT (FID,FSTOCKORGID,FKEEPERTYPEID,FKEEPERID,FOWNERTYPEID,FOWNERID,FSTOCKID,
FSTOCKLOCID,FAUXPROPID,FSTOCKSTATUSID,FLOT,FBOMID,FMTONO,FPROJECTNO,FPRODUCEDATE,
FEXPIRYDATE,FBASEUNITID,FBASEQTY,FBASELOCKQTY,FSECQTY,FSECLOCKQTY,FSTOCKUNITID,FMATERIALID,FQTY,FLOCKQTY,FSECUNITID,
FOBJECTTYPEID,FBASEAVBQTY,FAVBQTY,FSECAVBQTY)
VALUES(IT2.FINVENTORYID,IT2.FSTOCKORGID,IT2.FKEEPERTYPEID,IT2.FKEEPERID,IT2.FOWNERTYPEID,IT2.FOWNERID,IT2.FSTOCKID,
IT2.FSTOCKLOCID,IT2.FAUXPROPID,IT2.FSTOCKSTATUSID,IT2.FLOT,IT2.FBOMID,IT2.FMTONO,IT2.FPROJECTNO,IT2.FPRODUCEDATE,
IT2.FEXPIRYDATE,IT2.FBASEUNITID,IT2.FBASEQTY,0,IT2.FSECQTY,0,IT2.FSTOCKUNITID,IT2.FMATERIALID,0,0,IT2.FSECUNITID,
'STK_Inventory',0,0,0) ;
===================================================
推荐阅读