|
Execute the following
script in Query Editor to create 2 UDF-s for the money calculations:
USE AdventureWorks;
CREATE FUNCTION fnPresentValue (
@FutureValue Money,
@InterestRatePercent decimal,
@Years int )
RETURNS Money
AS
BEGIN
DECLARE @Value money
SELECT @Value = @FutureValue *(1/Power((1+@InterestRatePercent/100.0),@Years))
RETURN @Value
END
GO
-- SELECT dbo.fnPresentValue (500000, 5, 10)
CREATE FUNCTION fnFutureValue (
@PresentValue Money,
@InterestRatePercent decimal,
@Years int )
RETURNS Money
AS
BEGIN
DECLARE @Value money
SELECT @Value = @PresentValue * Power((1+@InterestRatePercent/100.0),@Years)
RETURN @Value
END
GO
-- SELECT dbo.fnFutureValue (1000000, 5, 10)
|