'Backup Database Before Process

update vs4tinventoryMB set tinmtwahcode=(select tlcttwahcode from 
vs4tlocation where tlctcode=tinmtlctcode) 

update vs4tinventorymb set tinmtintalias=(select tinvtintalias from vs4tinventory where tinmtinvno=tinvno)

update vs4tinventorymb set tinmflag2=(select tintinputcost from vs4tinventorytype where tintalias=tinmtintalias)

update vs4tinventorymb set tinmunitcost=
(select top 1 tinmunitcost from vs4Vinventory as a where a.tinmtpdtcode=vs4tinventorymb.tinmtpdtcode and a.tinminquantity>0 and a.tinmlotno=vs4tinventorymb.tinmlotno 
and a.tinmlotdate=vs4tinventorymb.tinmlotdate and a.tinvapprovestatus=1 and a.tinvcancelstatus=0 and a.tinmstatus=1 and a.tintinputcost=1)
where tinmflag2<>1

update vs4tinventorymb set tinminputcost=tinmunitcost,tinmlastunitcost=tinmunitcost
where tinmoutQuantity>0

update vs4tinventorymb set tinmamount=tinmunitcost*tinmamouquantity where tinmunitcalc=0
update vs4tinventorymb set tinmamount=tinmunitcost*tinmamouquantity2 where tinmunitcalc=1
update vs4tinventorymb set tinmamount=tinmunitcost*tinmamouquantity3 where tinmunitcalc=2