UPDATE VS4TAPBill Set TPBiFlagAPBill=(SELECT TOP 1 TPVRFlag1*2 FROM VS4TAPVDocRef inner join VS4TAPVoucher ON VS4TAPVoucher.TAPVNo=VS4TAPVDocRef.TPVRTAPVNo WHERE VS4TAPVoucher.TAPVApproveStatus=1 AND VS4TAPVoucher.TAPVCancelStatus=0
AND VS4TAPVDocRef.TPVRTAPVNo=VS4TAPBill.TPBiNo)
GO
UPDATE VS4TAPBill Set TPBiFlagAPBill=0 WHERE TPBiFlagAPBill is null
GO
