UPDATE VS4TInventoryLOT SET TIMCCostInputType=isnull((SELECT VS4TInventory2.TIn2CostManual FROM VS4TInventory2 WHERE VS4TInventory2.TIn2TInvNo=VS4TInventoryLOT.TIMCReceiveNo),0)+1
WHERE TIMCCostInputType=1 
GO