UPDATE VS4TARBill Set TBilFlagBill=(SELECT TOP 1 TRDRFlag1*2 FROM VS4TARVDocRef inner join VS4TARVoucher ON VS4TARVoucher.TRVHNo=VS4TARVDocRef.TRDRTRVHNo WHERE VS4TARVoucher.TRVHApproveStatus=1 AND VS4TARVoucher.TRVHCancelStatus=0
AND VS4TARVDocRef.TRDRRefBillNo=VS4TARBill.TBilNo)
GO
UPDATE VS4TARBill Set TBilFlagBill=0 WHERE TBilFlagBill is null
GO
