【问题描述】
某商品出入库明细中是正常显示,库存也是有结余的,在商品档案中显示库存为:0 库存查询中查不到库存。
请备份数据库后执行以下语句
–重算库存
use isszmv10
go
update t_im_branch_stock set stock_qty = aaa.qty
from
(select item_no,branch_no, sum(case db_no when ‘+’ then real_qty when ‘-‘ then -real_qty else 0 end)qty
from t_im_flow
group by item_no,branch_no) aaa
where t_im_branch_stock.item_no = aaa.item_no and t_im_branch_stock.branch_no = aaa.branch_no