Logo

SQL Server PMTSCHED Function

Updated 2023-10-06 23:12:52.507000

Description

Use the table-valued function PMTSCHED to generate an amortization schedule for a loan with no odd periods. The amortization schedule includes the payment number, the principal amount at the beginning of the period, the interest amount for the period, the principal payment for the period, and the ending principal amount.

Syntax

SELECT * FROM [westclintech].[wct].[PMTSCHED] (
  <@PV, float,>
 ,<@pmt, float,>
 ,<@NumPmts, int,>
 ,<@FV, float,>
 ,<@Pay_type, float,>)

Arguments

@PV

the principal amount of the loan or lease. @PV is an expression of type float or of a type that can be implicitly converted to float.

@pmt

The periodic loan payment. @pmt is an expression of type float or of a type that can be implicitly converted to float.

@NumPmts

the total number of payments to be recorded over the life of the loan. @NumPmts is an expression of type int or of a type that can be implicitly converted to int.

@FV

the future value at the end of the loan. @FV is an expression of type float or of a type that can be implicitly converted to float.

@Pay_type

Identifies whether payments are made at the beginning of the period (1) or at the end of the period (0).

Return Type

table

colNamecolDatatypecolDesc
num_pmtintThe payment number.
amt_prin_initfloatThe principal amount at the beginning of the period. For the first period, the principal amount is the amount of the loan, otherwise the principal amount is the ending principal amount from the prior period.
amt_int_payfloatThe interest payment amount for the period. The interest payment amount is equal to amt_prin_int – amt_prin_end - @pmt
amt_prin_payfloatThe principal payment amount for the period. The principal payment amount is equal to amt_prin_init – amt_prin_end.
amt_prin_endfloatThe ending principal amount. The ending principal amount is the present value of the remaining payments discounted using the implied rate from @pmt.

Remarks

@PV, @pmt, and @FV (when it is not zero) should have the same sign.

The rate value is equal to wct.RATE(@Numpmts,-@pmt,@PV,-@FV,@Pay_type,NULL).

Examples

Generate an amortization schedule for loan with a principal amount of 100,000 with 12 payments of 8606.64.

SELECT *
FROM wct.PMTSCHED(   100000,  --pv
                     8606.64, --pmt
                     12,      --numpmts
                     0,       --FV
                     0        --pay_type
                 );

This produces the following result.

num_pmtamt_prin_initamt_int_payamt_prin_payamt_prin_end
1100000499.9946139809768106.6453860190291893.354613981
291893.354613981459.4618236740218147.1781763259883746.176437655
383746.176437655418.7263716010938187.9136283989175558.2628092561
475558.2628092561377.7872444615798228.8527555384267329.4100537177
567329.4100537177336.6434238919618269.9965761080459059.4134776096
659059.4134776096295.293886435328311.3461135646850748.067364045
750748.067364045253.7376035182828352.9023964817242395.1649675632
842395.1649675632211.9735414249448394.6664585750634000.4985089882
934000.4985089882170.0006612705628436.6393387294425563.8591702587
1025563.8591702587127.8179189761728478.8220810238317085.0370892349
1117085.037089234985.42426524205088521.215734757958563.82135447697
128563.8213544769742.81864552303168563.821354476970

Generate an amortization schedule for loan with a principal amount of 32,000 with 60 payments of 600.95.

SELECT *
FROM wct.PMTSCHED(   32000,  --pv
                     600.95, --pmt
                     60,     --numpmts
                     0,      --FV
                     0       --pay_type
                 );

This produces the following result.

num_pmtamt_prin_initamt_int_payamt_prin_payamt_prin_end
132000127.996817638387472.95318236161331527.0468176384
231527.0468176384126.105051955211474.84494804478931052.2018695936
331052.2018695936124.205719385619476.74428061438130575.4575889792
430575.4575889792122.298789674637478.65121032536330096.8063786539
530096.8063786539120.384232434433480.56576756556829616.2406110883
629616.2406110883118.462017155692482.48798284430829133.752628244
729133.752628244116.532113206983484.41788679301728649.334741451
828649.334741451114.594489834405486.35551016559528162.9792312854
928162.9792312854112.649116161035488.30088383896527674.6783474464
1027674.6783474464110.695961186432490.25403881356827184.4243086328
1127184.4243086328108.734993786205492.21500621379526692.209302419
1226692.209302419106.766182711336494.18381728866426198.0254851304
1326198.0254851304104.789496587985496.16050341201525701.8649817184
1425701.8649817184102.804903916727498.14509608327425203.7198856351
1525203.7198856351100.812373072116500.13762692788424703.5822587072
1624703.582258707298.8118723023392502.13812769766124201.4441310095
1724201.444131009596.8033697283856504.14663027161423697.2975007379
1823697.297500737994.7868333438994506.16316665610123191.1343340818
1923191.134334081892.7622310143954508.18776898560522682.9465650962
2022682.946565096290.7295304769389510.22046952306122172.7260955732
2122172.726095573288.6886993394467512.26130066055321660.4647949126
2221660.464794912686.639705080411514.31029491958921146.154499993
2321146.15449999384.5825150480698516.3674849519320629.7870150411
2420629.787015041182.5170964602178518.43290353978220111.3541115013
2520111.354111501380.4434164033912520.50658359660919590.8475279047
2619590.847527904778.3614418325772522.58855816742319068.2589697373
2719068.258969737376.2711395705003524.678860429518543.5801093078
2818543.580109307874.1724763072737526.77752369272618016.802585615
2918016.80258561572.0654185997148528.88458140028517487.9180042148
3017487.918004214869.9499328708218531.00006712917816956.9179370856
3116956.917937085667.8259854094533533.12401459054716423.793922495
3216423.79392249565.6935423694551535.25645763054515888.5374648645
3315888.537464864563.5525697693113537.39743023068915351.1400346338
3415351.140034633861.4030334917363539.54696650826414811.5930681255
3514811.593068125559.2448992828024541.70510071719814269.8879674083
3614269.887967408357.0781327516481543.87186724835213726.01610016
3713726.0161001654.9026993698674546.04730063013313179.9687995299
3813179.968799529952.7185644708982548.23143552910212631.7373640008
3912631.737364000850.5256932495279550.42430675047212081.3130572503
4012081.313057250348.3240507613693552.62594923863111528.6871080117
4111528.687108011746.1136019221915554.83639807780910973.8507099338
4210973.850709933843.8943115074828557.05568849251710416.7950214413
4310416.795021441341.6661441518402559.283855848169857.51116559317
449857.5111655931739.4290643483284561.5209356516729295.9902299415
459295.990229941537.1830364481314563.7669635518698732.22326638963
468732.2232663896334.9280246596493566.0219753403518166.20129104928
478166.2012910492832.6639930482663568.2860069517347597.91528409754
487597.9152840975430.3909055356228570.5590944643777027.35618963317
497027.3561896331728.1087258989749572.8412741010256454.51491553214
506454.5149155321425.817417770729575.1325822292715879.38233330287
515879.3823333028723.5169446378598577.433055362145301.94927794073
525301.9492779407321.2072698412114579.7427301587894722.20654778194
534722.2065477819418.8883565750905582.061643424914140.14490435703
544140.1449043570316.5601678864798584.389832113523555.75507224351
553555.7550722435114.2226666746894586.7273333253112969.0277389182
562969.027738918211.8758156905126589.0741843094872379.95355460871
572379.953554608719.51957753578904591.4304224642111788.5231321445
581788.52313214457.15391466273582593.7960853372641194.72704680724
591194.727046807244.77878937348146596.171210626519598.55583618072
60598.555836180722.39416381928027598.555836180720

Generate an amortization schedule for 250,000 loan with 50,000 balloon payment with 36 payments of 6,533.74 using a CROSS APPLY.

SELECT k.*
FROM
(
    SELECT 250000 as pv,
           6533.74 as pmt,
           36 as numpmts,
           50000 as FV,
           0 as pay_type
) n
    CROSS APPLY wct.PMTSCHED(n.pv, n.pmt, n.numpmts, n.fv, n.pay_type) k;

This produces the following result.

num_pmtamt_prin_initamt_int_payamt_prin_payamt_prin_end
12500001562.494332746734971.24566725327245028.754332747
2245028.7543327471531.42416002165002.3158399784240026.438492768
3240026.4384927681500.159799419355033.58020058065234992.858292188
4234992.8582921881468.700037271845065.03996272816229927.81832946
5229927.818329461437.043652324255096.69634767575224831.121981784
6224831.1219817841405.189415688295128.55058431171219702.571397472
7219702.5713974721373.136090795645160.60390920436214541.967488268
8214541.9674882681340.882433348695192.85756665131209349.109921616
9209349.1099216161308.427191274025225.31280872598204123.79711289
10204123.797112891275.769104672145257.97089532786198865.826217563
11198865.8262175631242.90690576955290.8330942305193574.993123332
12193574.9931233321209.839318868255323.90068113175188251.0924422
13188251.09244221176.56506029895357.1749397011182893.917502499
14182893.9175024991143.082838367335390.65716163267177503.260340867
15177503.2603408671109.391353308125424.34864669188172078.911694175
16172078.9116941751075.489297230855458.25070276915166620.660991405
17166620.6609914051041.375354071865492.36464592814161128.296345477
18161128.2963454771007.048199541185526.69180045882155601.604545019
19155601.604545019972.5065010727945561.23349892721150040.371046091
20150040.371046091937.7489177720955595.99108222791144444.379963863
21144444.379963863902.7741003637295630.96589963627138813.414064227
22138813.414064227867.5806911396895666.15930886031133147.254755367
23133147.254755367832.1673239052855701.57267609471127445.682079272
24127445.682079272796.5326239286315737.20737607137121708.474703201
25121708.474703201760.6752078849915773.06479211501115935.409911086
26115935.409911086724.5936838039295809.14631619607110126.26359489
27110126.26359489688.2866510154075845.45334898459104280.810245905
28104280.810245905651.7527000947255881.9872999052898398.8229459998
2998398.8229459998614.9904128089645918.7495871910492480.0733588088
3092480.0733588088577.998362061465955.7416379385486524.3317208702
3186524.3317208702540.7751118349935992.9648881650180531.3668327052
3280531.3668327052503.3192171384676030.4207828615374500.9460498437
3374500.9460498437465.6292239494016068.110776050668432.8352737931
3468432.8352737931427.7036691568886106.0363308431162326.79894295
3562326.79894295389.5410805069936144.1989194930156182.600023457
3656182.600023457351.1399765430346182.6000234569750000

Generate an amortization schedule for a 10,000 loan with 12 monthly payments of 869.95, made at the beginning of the period using CROSS APPLY.

SELECT k.*
FROM
(
    SELECT 10000 as pv,
           869.95 as pmt,
           12 as numpmts,
           0 as FV,
           1 as pay_type
) n
    CROSS APPLY wct.PMTSCHED(n.pv, n.pmt, n.numpmts, n.fv, n.pay_type) k;

This produces the following result.

    num_pmt          amt_prin_init            amt_int_pay           amt_prin_pay           amt_prin_end
----------- ---------------------- ---------------------- ---------------------- ----------------------
          1                  10000       72.2834188150475       797.666581184953       9202.33341881505
          2       9202.33341881505       65.9682214653596        803.98177853464       8398.35164028041
          3       8398.35164028041       59.6030261359176       810.346973864082       7588.00466641632
          4       7588.00466641632       53.1874369882901        816.76256301171       6771.24210340461
          5       6771.24210340461       46.7210550501161       823.228944949884       5948.01315845473
          6       5948.01315845473       40.2034781903678       829.746521809632        5118.2666366451
          7        5118.2666366451       33.6343010942358       836.315698905764       4281.95093773933
          8       4281.95093773933       27.0131152381475       842.936884761853       3439.01405297748
          9       3439.01405297748       20.3395088640143       849.610491135986        2589.4035618415
         10        2589.4035618415        13.613066954043       856.336933045957       1733.06662879554
         11       1733.06662879554       6.83337120446595       863.116628795534       869.950000000005
         12       869.950000000005  -4.77484718430787E-12       869.950000000005                      0