Reference .NET Assembly from a SQL Server Stored procedure or function

纵饮孤独 提交于 2019-12-12 12:17:18

问题


Is it possible to reference a .NET Assembly from a SQL Server Stored procedure or function, or otherwise access the clr code from SQL Server?

EDIT Whilst this solution will require to be somewhat generic, I am fairly confident expecting SQL 2005+


回答1:


It depends on your version of SQL Server. SQL Server 2005 and higher supports CLR Stored Procedures. If you have an older version, you need to register the Assembly as a COM class (using attributes on the objects/methods/assembly), and then registering it using regasm. Then you can call it like any other COM Object.

http://dn.codegear.com/article/32754

SQL 6.5 is a bit buggy though (leaks memory occasionally), so you might need to register it as a COM+ Component (in my experience). That might not stop the memory leaks, but it can help prevent the "Class not found" errors. I'm not exactly sure why it occurs in 6.5

http://msdn.microsoft.com/en-us/library/ms189763.aspx




回答2:


You can indeed.

Some information here.




回答3:


CLR Stored procedures

Sql Server 2005 or later required.



来源:https://stackoverflow.com/questions/136818/reference-net-assembly-from-a-sql-server-stored-procedure-or-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!