update vs4tproduct set tpdtlastbaldate =(select top 1 tinvdate from VS4TInventory INNER JOIN VS4TInventoryMB ON VS4TInventory.TInvNo = VS4TInventoryMB.TInMTInvNo where tinmtpdtcode=tpdtcode
and tinvapprovestatus=1 and tinvcancelstatus=0 and tinmstatus=1 ORDER BY TinvDate)
GO
update vs4tproduct set tpdtlastbaldate =(select tsysvalue from vs4tsystem where tsysname='StartSystemDate')
where tpdtlastbaldate is null
GO