结账提示不能插入重复值

问题处理1、通过数据库跟踪,提示不能在表T_cc_stock主键插入重复值,开始不知道是哪个键值重复,于是到企业管理器里面修改这个表不受主键约束,结帐通过,通过下面这段代码找出重复值
select fyear,fperiod,fstockid,fitemid,fbatchno,fauxpropid from t_cc_stock group by fyear,fperiod,fstockid,fitemid,fbatchno,fauxpropid having count(*)>1
发现有两条重复,不知道为什么金蝶商贸版在使用日期管理的时候,同一个批号可以录入不同的开始日期和结束日期,也许是金蝶商贸版的一个BUG吧,因为在期抹结帐时提取的分组求和字段有这两个字段fperioddate,fkfdate,
2、找出两个相同的记录,修改批号对应同等的开始和结束日期后,期末结帐通过
select fitemid,fbatchno,fauxpropid,min(fkfdate) as
fkfdate,min(fperioddate) as fperioddate into temp1
from t_cc_stockbillentry
group by fitemid ,fbatchno,fauxpropid
update a set a.fkfdate=b.fkfdate,a.fperioddate=b.fperioddate from
t_cc_stockbillentry a inner join temp1 b on a.fitemid=b.fitemid and a.fbatchno=b.fbatchno and a.fauxpropid=b.fauxpropid
update a set a.fkfdate=isnull(b.fkfdate,'1900-01-01 00:00:00.000'),a.fperioddate=isnull(b.fperioddate,'1900-01-01 00:00:00.000')
from t_cc_stock a inner join temp1 b on a.fitemid=b.fitemid and a.fbatchno=b.fbatchno and
结账提示不能插入重复值
声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。如若本站内容侵犯了原著者的合法权益,可联系本站删除。



