UPDATE VS4TARinvoice Set TIvoCancelStatus=(SELECT TRCNCancelStatus From VS4TARCreditNote
WHERE VS4TARCreditNote.TRCNNo=VS4TARinvoice.TIvoNo) WHERE TIvoType >=20 and TIvoType<30
GO
UPDATE VS4TARinvoice Set TIvoConfirmStatus=(SELECT TRCNConfirmStatus From VS4TARCreditNote
WHERE VS4TARCreditNote.TRCNNo=VS4TARinvoice.TIvoNo) WHERE TIvoType >=20 and TIvoType<30
GO
UPDATE VS4TARinvoice Set TIvoApproveStatus=(SELECT TRCNApproveStatus From VS4TARCreditNote
WHERE VS4TARCreditNote.TRCNNo=VS4TARinvoice.TIvoNo) WHERE TIvoType >=20 and TIvoType<30
GO

UPDATE VS4TARinvoice Set TIvoCancelStatus=(SELECT TDBNCancelStatus From VS4TARDebitNote
WHERE VS4TARDebitNote.TDBNNo=VS4TARinvoice.TIvoNo) WHERE TIvoType>=30
GO
UPDATE VS4TARinvoice Set TIvoConfirmStatus=(SELECT TDBNConfirmStatus From VS4TARDebitNote
WHERE VS4TARDebitNote.TDBNNo=VS4TARinvoice.TIvoNo) WHERE TIvoType>=30
GO
UPDATE VS4TARinvoice Set TIvoApproveStatus=(SELECT TDBNApproveStatus From VS4TARDebitNote
WHERE VS4TARDebitNote.TDBNNo=VS4TARinvoice.TIvoNo) WHERE TIvoType>=30
GO

UPDATE VS4TAPinvoice Set TIAPCancelStatus=(SELECT TPCNCancelStatus From VS4TAPCreditNote
WHERE VS4TAPCreditNote.TPCNNo=VS4TAPinvoice.TIAPNo) WHERE TIAPType >=20 and TIAPType<30
GO
UPDATE VS4TAPinvoice Set TIAPConfirmStatus=(SELECT TPCNConfirmStatus From VS4TAPCreditNote
WHERE VS4TAPCreditNote.TPCNNo=VS4TAPinvoice.TIAPNo) WHERE TIAPType >=20 and TIAPType<30
GO
UPDATE VS4TAPinvoice Set TIAPApproveStatus=(SELECT TPCNApproveStatus From VS4TAPCreditNote
WHERE VS4TAPCreditNote.TPCNNo=VS4TAPinvoice.TIAPNo) WHERE TIAPType >=20 and TIAPType<30
GO

UPDATE VS4TAPinvoice Set TIAPCancelStatus=(SELECT TDENCancelStatus From VS4TAPDebitNote
WHERE VS4TAPDebitNote.TDENNo=VS4TAPinvoice.TIAPNo) WHERE TIAPType>=30
GO
UPDATE VS4TAPinvoice Set TIAPConfirmStatus=(SELECT TDENConfirmStatus From VS4TAPDebitNote
WHERE VS4TAPDebitNote.TDENNo=VS4TAPinvoice.TIAPNo) WHERE TIAPType>=30
GO
UPDATE VS4TAPinvoice Set TIAPApproveStatus=(SELECT TDENApproveStatus From VS4TAPDebitNote
WHERE VS4TAPDebitNote.TDENNo=VS4TAPinvoice.TIAPNo) WHERE TIAPType>=30
GO