旗舰版存货核算期末结账提示“违反了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'中插入重复键”?
本文2024-09-22 16:38:24发表“kis知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-kis-89240.html