解决方案: |
您好,
经查数据表,在结算单子表中,存在错误记录。baccount字段有异常,正常情况下,存货明细账中的非暂估和暂估已报销单据的报销数量汇总,应与结算单表的已结算记录的汇总数量相同,但此数据中,这两个值不等,需要调整。具体脚本如下:
--通过明细账和结算单子表,检查结算单表错误记录,并插入临时表
select a.id, a.q --into tempa
from
(select sum(iainquantity) as q, id from ia_subsidiary where (bflag = 0 or bflag = 2) and cvoutype in ('01','30')
group by id)a
left join
(select sum(isvquantity) as q, irdsid from PurSettleVouchs where baccount = 1
group by irdsid)b
on a.id = b.irdsid
where a.q <> isnull(b.q,0)
go
--更新baccount字段为正确值
update pursettlevouchs set baccount = 1
where irdsid in (select id from tempa)
go
--删除临时表
drop table tempa
go
|