UPDATE VS4TARCARD Set TRICDocType=(SELECT TSODType FROM VS4TSO WHERE VS4TARCARD.TRICDocNo=VS4TSO.TSODNo) WHERE (TRICType='O')
GO
UPDATE VS4TARCARD Set TRICDocType=(SELECT TIVOType FROM VS4TARInvoice WHERE VS4TARCARD.TRICDocNo=VS4TARInvoice.TIVONo) WHERE (TRICType='I')
GO
UPDATE VS4TARCARD Set TRICDocType=(SELECT TRCNType FROM VS4TARCreditNote WHERE VS4TARCARD.TRICDocNo=VS4TARCreditNote.TRCNNo) WHERE (TRICType='C')
GO
UPDATE VS4TARCARD Set TRICDocType=(SELECT TDBNType FROM VS4TARDebitNote WHERE VS4TARCARD.TRICDocNo=VS4TARDebitNote.TDBNNo) WHERE (TRICType='D')
GO
UPDATE VS4TARCARD Set TRICDocType=(SELECT TRVHType FROM VS4TARVoucher WHERE VS4TARCARD.TRICDocNo=VS4TARVoucher.TRVHNo) WHERE (TRICType='P' OR TRICType='H')
GO
UPDATE VS4TARCARD Set TRICDocType=0 WHERE TRICDocType is Null
GO