Update VS4TInvoice Set TIvoDiscountTotal=(select sum(TIoMDiscountTotal) from VS4TInvoiceMB WHERE TIoMTIvoNo=TIvoNo)
Update VS4TARCreditNote Set TRCNDiscountTotal=(select sum(TRCMDiscountTotal) from VS4TARCreditNoteMB WHERE TRCMTRCNNo=TRCNNo)
Update VS4TARDebitNote Set TDBNDiscountTotal=(select sum(TDBMDiscountTotal) from VS4TARDebitNoteMB WHERE TDBMTDBNNo=TDBNNo)

Update VS4TAPInvoice Set TIAPDiscountTotal=(select sum(TIPMDiscountTotal) from VS4TAPInvoiceMB WHERE TIPMTIAPNo=TIAPNo)
Update VS4TAPCreditNote Set TPCNDiscountTotal=(select sum(TPCMDiscountTotal) from VS4TAPCreditNoteMB WHERE TPCMTPCNNo=TPCNNo)
Update VS4TAPDebitNote Set TDENDiscountTotal=(select sum(TDEBDiscountTotal) from VS4TAPDebitNoteMB WHERE TDEBTDENNo=TDENNo)