



----------------------备用-------------------
update inigoodsstocks set total=qty*price where  qty<=0 or total<=0
delete  from inigoodsstocks where qty<0 or total<0    --会将负库存的数量或金额删除
delete  from inigoodsstocks where qty=0 AND  total=0  
delete inigoodsstocks where prec not in(select rec from ptype where sonnum=0 and deleted=0)
delete inigoodsstocks where krec not in(select rec from stock where sonnum=0 and deleted=0)
update I
set I.Grec= G.rec
from inigoodsstocks i,
(select krec,rec from klocation where deleted=0 and locationtype=1) g
where i.krec=g.krec
and grec not in(select rec from klocation where deleted=0)

update I
set I.providerid='0'
from inigoodsstocks i
where
ltrim(providerid) not in(select rec from btype where sonnum=0 and deleted=0 union select '0' union select '')
