update vs4tinventorymb set tinmunitratio=(select timcunitratio from vs4tinventorylot where vs4tinventorylot.timctpdtcode=vs4tinventorymb.tinmtpdtcode
and vs4tinventorylot.timclotno=vs4tinventorymb.tinmlotno and vs4tinventorylot.timclotdate=vs4tinventorymb.tinmlotdate
and vs4tinventorylot.timcserialno=vs4tinventorymb.tinmserialno and vs4tinventorylot.timccustom1 = vs4tinventorymb.tinmcustom1)

update vs4tinventorymb set tinmamouquantity=tinmquantitycalc where tinmamouquantity<>0 
GO
update vs4tinventorymb set tinmquantitybase=tinmamouquantity/tinmunitratio where tinmamouquantity<>0 
GO
update vs4tinventorymb set tinminquantity=abs(tinmamouquantity) where tinmamouquantity>0 
GO
update vs4tinventorymb set tinmoutquantity=abs(tinmamouquantity) where tinmamouquantity<0 
GO