UPDATE VS4TAPCARD Set TPICDocType=(SELECT TPODType FROM VS4TPO WHERE VS4TAPCARD.TPICDocNo=VS4TPO.TPODNo) WHERE (TPICType='O')
GO
UPDATE VS4TAPCARD Set TPICDocType=(SELECT TIAPType FROM VS4TAPInvoice WHERE VS4TAPCARD.TPICDocNo=VS4TAPInvoice.TIAPNo) WHERE (TPICType='I')
GO
UPDATE VS4TAPCARD Set TPICDocType=(SELECT TPCNType FROM VS4TAPCreditNote WHERE VS4TAPCARD.TPICDocNo=VS4TAPCreditNote.TPCNNo) WHERE (TPICType='C')
GO
UPDATE VS4TAPCARD Set TPICDocType=(SELECT TDENType FROM VS4TAPDebitNote WHERE VS4TAPCARD.TPICDocNo=VS4TAPDebitNote.TDENNo) WHERE (TPICType='D')
GO
UPDATE VS4TAPCARD Set TPICDocType=(SELECT TAPVType FROM VS4TAPVoucher WHERE VS4TAPCARD.TPICDocNo=VS4TAPVoucher.TAPVNo) WHERE (TPICType='P' OR TPICType='H')
GO
UPDATE VS4TAPCARD Set TPICDocType=0 WHERE TPICDocType is Null
GO