速达5000系列
上海速达软件建议您:
只能从后台修复数据:
--修复期初库存
insert into aa_storebalance
select 2010 posyear,10 posmonth,storeid,goodsid,quantity bqty,
price bprice,amount bamount,0.0 inqty,0.0 inamount,0.0 outqty,
0.0 outamtqty,quantity eqty,price eprice ,amount eamount,quantity brqty,
0.0 inrqty,0.0 outrqty,0.0 erqty,0.0 bextqty,0.0 inextqty,
0.0 outextqty,0.0 eextqty,0.0 brextqty,0.0 inrextqty,0.0 outrextqty,
0.0 erextqty
from aa_billflow
where billtype < 0 and quantity <> 0 and
cast(storeid as varchar(2))+cast(goodsid as varchar(20)) not in
(select cast(storeid as varchar(2))+ cast(goodsid as varchar(20))
from aa_storebalance
where posyear = 2010 and posmonth =10
)
go
update aa_storebalance set bqty = bb.bqty
from aa_storebalance aa,
(select a.quantity bqty,a.goodsid,a.storeid
from aa_storebalance b,aa_billflow a
where a.goodsid=b.goodsid and a.storeid =b.storeid and b.posyear=2010 and b.posmonth=10
and b.bqty<>a.quantity and a.billtype < 0 and a.quantity <> 0
) as bb
where aa.storeid=bb.storeid and aa.goodsid=bb.goodsid and aa.posyear=2010 and aa.posmonth =10
and aa.bqty <> bb.bqty
go
--这两个数应一致
select * from
(select sum(quantity) bqty from aa_billflow where billtype < 0
union all
select sum(bqty) bqty from aa_storebalance where posmonth =10 and posyear =2010
) as mm