Below script is my actual script to solve or detach data I need.
They are :
RemainingTermBeforeModification ; currentAmterm ; maximumPaymentterm_NPV ; maximumAMTerm_NPV ; AmortizationTermBeforeModification_DATA ; MaturityDateBeforeModification_DATA
However, these columns are in Stored Procedure [Socrates_NPVWaterfallInputsforPaymentandAMTerm_xp].
a. Then we need execute the Stored Procedure and get those vaules.
But we just need the last values of the Stored Procedure. Moreover, we need prepare those values we do not need.
b. So we select them from Table [mspbal] and inner join some necessary and associated tables.
Finally, I get all the values I need detect.
Here is all the detail :
DECLARE
@agreementId int,
@rundate datetime,
@lastestmaturity smalldatetime,
@maturity datetime,
@loanterm1 int,
--@loanterm int,
@firstpaydue datetime,
@currentterm int,
@currentAmterm int,
@maximumPaymentterm int,
@maximumAMTerm int
select @agreementid = agreementid ,
@lastestmaturity = LatestLoanMaturity,
@rundate =GETDATE(),--'2016-01-05',
@maturity = maturity,
@loanterm1 = loanterm,
@firstpaydue = fst_paydue
from mspbal m join lighthousebase lb on m.sanbankcatid = lb.sanbankcatid
join originfo o on m.loan_no = o.loan_no
where m.loaN_no = '0017791914'
EXEC Socrates_NPVWaterfallInputsforPaymentandAMTerm_xp
@agreementId
,@rundate
,@lastestmaturity
,@maturity
,@loanterm1 -- originfo.loanterm
,@firstpaydue -- Originfo.fst_paydue
,@currentterm output --data.RemainingTermBeforeModification
,@currentAmterm output
,@maximumPaymentterm output --sdnpv
,@maximumAMTerm output --sdnpv
select @currentterm as RemainingTermBeforeModification
,@currentAmterm as currentAmterm
,@maximumPaymentterm as maximumPaymentterm_NPV
,@maximumAMTerm as maximumAMTerm_NPV
,@loanterm1 as AmortizationTermBeforeModification_DATA
,@maturity as MaturityDateBeforeModification_DATA
Here is result :
All I must do is remember these scripts and review them often when I need.