Don’t call into the CLR from SQL Server

less than 1 minute read

From time to time I’ve considered making a call from a SQL Server stored proc into a .NET assembly via COM Interop using the sp_OA stored procedures as a mechanism to perform some database triggered activity (say from a scheduled job). I’ve always found a different solution in the end and it turns out to have been lucky that I did so:

Q322884 - INF: Using Extended Stored Procedures or SP_OA Stored Procedures to Load CLR in SQL Server Is Not Supported

To increase performance, the CLR internally uses thread-local-storage (TLS) which isn’t allowed inside the SQL Server memory space. In addition, SQL may be configured to use fibers, which the CLR additionally doesn’t support.

Updated: