UPDATE VS4TGLTrans SET TGLTDescription='ขายสินค้า ให้กับ '+(SELECT TIvoCustomerName FROM VS4TARInvoice WHERE VS4TARInvoice.TIvoNo=VS4TGLTrans.TGLTNo) where tgltdescription like 'ARInvoice%' and TGLTInputSource='IV'
GO

UPDATE VS4TGLTrans SET TGLTDescription='ขายบริการ ให้กับ '+(SELECT TIvoCustomerName FROM VS4TARInvoice WHERE VS4TARInvoice.TIvoNo=VS4TGLTrans.TGLTNo) where tgltdescription like 'ARReceipt%' and TGLTInputSource='IV'
GO

UPDATE VS4TGLTrans SET TGLTDescription='ซื้อสินค้า จาก '+(SELECT TIAPSupplierName FROM VS4TAPInvoice WHERE VS4TAPInvoice.TIAPNo=VS4TGLTrans.TGLTNo)+' ['+(SELECT TIAPRefNo FROM VS4TAPInvoice WHERE VS4TAPInvoice.TIAPNo=VS4TGLTrans.TGLTNo)+']' where tgltdescription like 'APInvoice%' and TGLTInputSource='PIV'
GO