我们可以从Sql Server调用.Net Dll吗 [英] Can we call .Net Dll from Sql Server
本文介绍了我们可以从Sql Server调用.Net Dll吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我在.Net dll文件中有一个函数.我只想从Sql Server调用该函数.有人可以帮我吗...
谢谢,
Prasant
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
推荐答案
显然,您可以.
此链接讨论有关直接调用.NET程序集的信息:
在SQL Server 2005下执行.NET代码 [ http://www32.brinkster.com/srisamp/sqlArticles/article_33.htm [ ^ ]
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[^]
否.
您不能从SQL Server内部调用.NET函数,只能以其他方式调用.
No.
You cannot call .NET functions from within SQL server, only the other way around.
您需要将dll作为程序集添加到数据库中.
You need to add the dll as an assembly in the database.
--=============================================================
-- 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
这篇关于我们可以从Sql Server调用.Net Dll吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文