Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
3.67/5 (3 votes)
See more:
Hi All,

I have a function in .Net dll file.I just wanted to call that function from Sql Server.Could anyone help me on this please...

Thanks,
Prasant
Posted

Apparently, you can.

This link talks about calling your .NET assembly directly:
Execute .NET Code under SQL Server 2005[^]

While this link talks about generating a COM wrapper and calling the COM wrapper:
http://www32.brinkster.com/srisamp/sqlArticles/article_33.htm[^]
 
Share this answer
 
v2
You need to add the dll as an assembly in the database.

SQL
--=============================================================
-- Create Assembly Template
--=============================================================
IF EXISTS(
    SELECT *
      FROM sys.assemblies
     WHERE name = N'<assembly_name, SYSNAME, MyClass>'
)
DROP ASSEMBLY <assembly_name, SYSNAME, MyClass>;
GO

CREATE ASSEMBLY <assembly_name, SYSNAME, MyClass>
FROM N'<Assembly_DLL_Name, nvarchar(4000), Path_MyAssembly.dll>'
WITH PERMISSION_SET = <Safe_External_Access_Unsafe, , SAFE>;
GO
 
Share this answer
 
No.
You cannot call .NET functions from within SQL server, only the other way around.
 
Share this answer
 
Comments
[no name] 14-Jul-11 14:35pm    
Actually, you can. See my answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900