UPDATE VS4TAPvdocref SET TPVRCurDiscount=0 WHERE TPVRCurDiscount is null
GO
UPDATE VS4TAPVoucherPay SET TPVPAmount=0 WHERE TPVPAmount is null
GO
UPDATE VS4TAPVoucher SET TAPVDiscount=((select isnull(sum(TPVPAmount),0) from VS4TAPVoucherPay where TPVPPaymentType='DISCOUNT' AND VS4TAPVoucherPay.TPVPTAPVNo=VS4TAPVoucher.TAPVno) +
(select isnull(sum(TPVRCurDiscount),0) from VS4TAPvdocref where VS4TAPvdocref.TPVRTAPVNo=VS4TAPVoucher.TAPVno))
GO
UPDATE VS4TAPVoucher SET TAPVDiscount=0 WHERE TAPVDiscount is null
GO