服务热线:

400-665-0027

知识资讯
联系我们

电话:400-665-0027


您当前位置:首页 > 知识资讯  > 知识学习 > 正文知识学习
金蝶旗舰版存货核算期末结账提示违反了PRIMARY KEY约束pk_POInvBal不能在对象dbo.POInvBal中插入重复键。
服务热线:400-665-0027 新购有特价、金蝶老客户升级金蝶云产品可以享受5折优惠,送手机、送话费,好礼不断!
【问题描述】

旗舰版存货核算期末结账提示“违反了PRIMARY KEY约束'pk_POInvBal'不能在对象'dbo.POInvBal'中插入重复键?




【原因分析】
原因1:虚仓余额表POInvBal中存在以后期间的数据。

原因2:虚仓余额表POInvBal中存在已被删除的物料。


【解决方案】
--针对原因1,可参考以下脚本执行处理:
declare @FCurrentYear int
declare @FCurrentPeriod int
select @FCurrentYear = FValue from t_SystemProfile where FCategory = 'IC' and FKey = 'currentyear'
select @FCurrentPeriod = FValue from t_SystemProfile where FCategory = 'IC' and FKey = 'currentperiod'
delete from POInvBal where FYear * 1000 + FPeriod > @FCurrentYear * 1000 + @FCurrentPeriod
--针对原因2,可参考以下脚本执行处理:
delete from POInvBal  where FItemID not in(select FItemID from  t_ICItem)

【注意事项】
1、正式账套执行脚本前请先做好备份,建议待在测试账套中核实无误后再在正式账套中执行。
2、本条知识针对特定的账套数据进行分析,并不代表相同的报错一定就是这个原因引发,相关的修复SQL也不适合直接使用,主要供读者参考,请读者根据实际情况具体分析。