UPDATE VS4TInventory Set TInvTotalRecord=(SELECT COUNT(VS4TInventoryMB.TInMLn) FROM VS4TInventoryMB
WHERE VS4TInventoryMB.TInMShow=1 AND VS4TInventoryMB.TInMTInvNo=VS4TInventory.TInvNo)
WHERE TINVTInTAlias='BEGINBALANCE' AND TInvSourceType=9
GO
UPDATE VS4TInventory Set TInvTotalRecord=1 WHERE TInvTotalRecord is Null
GO