A SQL CLR project that enables IRR (Internal Rate of Return) calculations to be done in SQL Server, helping you to replace those pesky Excel Spreadsheets
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
ClrTest
.gitattributes
.gitignore
ClrTest.sln
README.md

README.md

SqlIRR

I assume that if you have got here you are looking for a way to calculate IRR from a T-SQL script or stored procedure. I also assume you are familiar with SQL Server Database Projects.

Setup and deployment

The project is a Visual Studio 2017 database project and is configured to deploy just the CLR and to create a function (dbo.SqlIRR). Before you deploy you will need to do the following:

Sign the assembly in the project's Properties\SQLCLR\Signing dialog.

Enable CLR functions for your SQL Server (if not already enabled) to do this issue the following commands (needs sysadmin permissions)

sp_configure 'show advanced options', 1;  
GO  
RECONFIGURE;  
GO  
sp_configure 'clr enabled', 1;  
GO  
RECONFIGURE;  
GO 

Usage

    DECLARE @Revenues AS NVARCHAR(MAX) = '-3000, 1850, 1400, 1000'
    SELECT dbo.SqlIRR(@Revenues)

This project is heavily based on the work of Joseph A. Nyirenda and Mai Kalange. You can find more information about this at http://zainco.blogspot.com/2008/08/internal-rate-of-return-using-newton.html