Simple Interest Calculation Function in SQL Server
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.
As can be seen, the two-year interest rate of 10 percent has been calculated.
Good luck to everyone in business and life.