Simple Interest Calculation Function in SQL Server

Hello everyone,

In this article, I will try to give information about the simple interest calculation function in SQL Server.

In SQL Server, in some cases, you may want to calculate interest simply.

You can easily do this using the function below.

CREATE FUNCTION dbo.SimpleInterestFunction
(
    @Principal DECIMAL(18, 2) = 0.0,
    @InterestRate DECIMAL(18, 2) = 0.0,
    @TimeinYears DECIMAL(18, 2) = 0.0
)
RETURNS INT
AS
BEGIN
    RETURN (@Principal * @InterestRate * @TimeinYears / 100);
END;
GO


--Using Function

SELECT dbo.SimpleInterestFunction(1000,10,2)

When you create and run the above function, you will see a result similar to the one below.

Simple Interest Calculation Function in SQL Server

As can be seen, the two-year interest rate of 10 percent has been calculated.

Good luck to everyone in business and life.

223 Views

Yavuz Selim Kart

I try to explain what I know in software and database. I am still improving myself by doing research on many programming languages. Apart from these, I am also interested in Graphic Design and Wordpress. I also have knowledge about SEO and Social media management. In short, I am a determined person who likes to work hard.

You may also like...

Don`t copy text!