UPDATE VS4TARInvoice Set TIvoApproveStatus=(SELECT TRCNApprovestatus FROM VS4TARCreditNote WHERE  VS4TARCreditNote.TRCNNo=VS4TARInvoice.TIvoNo) WHERE TIvoType=20
GO
UPDATE VS4TARInvoice Set TIvoApproveStatus=(SELECT TDBNApprovestatus FROM VS4TARDebitNote WHERE  VS4TARDebitNote.TDBNNo=VS4TARInvoice.TIvoNo) WHERE TIvoType=30
GO
UPDATE VS4TAPInvoice Set TIAPApproveStatus=(SELECT TPCNApprovestatus FROM VS4TAPCreditNote WHERE  VS4TAPCreditNote.TPCNNo=VS4TAPInvoice.TIAPNo) WHERE TIAPType=20
GO
UPDATE VS4TAPInvoice Set TIAPApproveStatus=(SELECT TDENApprovestatus FROM VS4TAPDebitNote WHERE  VS4TAPDebitNote.TDENNo=VS4TAPInvoice.TIAPNo) WHERE TIAPType=30
GO
