update vs4tinventoryMB set tinmunitcalc=(select tinmunitcalc from vs4tinventoryLOT where 
vs4tinventoryMB.tinmtpdtcode=vs4tinventoryLOT.timctpdtcode and vs4tinventoryMB.tinmlotno=vs4tinventoryLOT.timclotno
and vs4tinventoryMB.tinmcustom1=vs4tinventoryLOT.timccustom1
and vs4tinventoryMB.tinmlotdate=vs4tinventoryLOT.timclotdate
and vs4tinventoryMB.tinmserialno=vs4tinventoryLOT.timcserialno)
GO
update vs4tinventoryMB set tinmunitcalc=0 WHERE tinmunitcalc is NULL
GO
update vs4tinventorymb set tinmquantitycalc=tinmamouquantity where tinmunitcalc=0 
GO
update vs4tinventorymb set tinmquantitycalc=tinmamouquantity2 where tinmunitcalc=1
GO
update vs4tinventorymb set tinmquantitycalc=tinmamouquantity3 where tinmunitcalc=2
GO
