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

栏目:kis知识作者:金蝶来源:金蝶云社区发布:2024-09-22浏览:2

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

【问题描述】

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

【原因分析】

该现象可能出现在反结账重新结账,或结账不成功再次结账时。该问题的原因为余额表中存在以后期间的数据。

【解决方案】

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 ICInvBal where FYear * 1000 + FPeriod > @FCurrentYear * 1000 + @FCurrentPeriod

delete from POInvBal where FYear * 1000 + FPeriod > @FCurrentYear * 1000 + @FCurrentPeriod

delete from ICBal where FYear * 1000 + FPeriod > @FCurrentYear * 1000 + @FCurrentPeriod

delete from ICVMIInvBal where FYear * 1000 + FPeriod > @FCurrentYear * 1000 + @FCurrentPeriod

【注意事项】

正式账套执行脚本前请先做好备份,建议待在测试账套中核实无误后再在正式账套中执行。

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

【问题描述】旗舰版存货核算期末结账提示“违反了PRIMARY KEY约束'pk ICInvBal'。不能在对象'dbo.ICInvBal'中插入重复键...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息