UPDATE VS4TChequeRec Set TCHRChqPassDate=(select TOP 1 TGLTDate from vs4tgltrans where TGLTInputSource='RCQ' AND TGLTCancelStatus = 0 AND VS4TChequeRec.TCHRNo=vs4tgltrans.TGLTRefNo ORDER BY TGLTDate DESC,TGLTFlag3 DESC) WHERE TCHRChqStatus=2
GO

UPDATE VS4TChequeRec Set TCHRChqPassDate=(select TOP 1 TGLTDate from vs4tgltrans where TGLTInputSource='XRCQ' AND TGLTCancelStatus = 0 AND VS4TChequeRec.TCHRNo=vs4tgltrans.TGLTRefNo ORDER BY TGLTDate DESC,TGLTFlag3 DESC) WHERE TCHRChqStatus=3
GO
