UPDATE VS4TAPVDocRef Set TPVRRefDocAmount=isnull((SELECT TIAPGrandTotal FROM VS4TAPInvoice WHERE VS4TAPInvoice.TIapNo=VS4TAPVDocRef.TPVRTAPVNo and VS4TAPInvoice.tiaptype=1),0) WHERE TPVRRefDocAmount=0 AND TPVRCurAmount=0 AND TPVRAmountRate=0
GO
UPDATE VS4TAPVDocRef Set TPVRCurAmount=TPVRRefDocAmount,TPVRAmountRate=TPVRRefDocAmount WHERE TPVRCurAmount=0 AND TPVRAmountRate=0
GO