参考.NET程序集从SQL Server存储过程或函数存储过程、函数、程序、NET

2023-09-05 00:34:44 作者:那场戏里つ我的角色是小丑

是否有可能引用一个.NET程序集从SQL Server存储过程或函数,或从SQL Server访问CLR code?

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?

修改虽然这个解决方案将需要有点通用的,我相当有信心期待SQL 2005 +

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

推荐答案

这要看你的SQL Server版本。 SQL Server 2005和更高版本支持CLR存储过程。如果你有一个旧的版本,你需要注册大会作为一个COM类(使用对象/方法/组件的属性),然后注册它使用regasm。然后,你可以调用它像任何其他COM对象。

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.$c$cgear.com/article/32754

SQL 6.5是一个有点马车虽然(泄漏内存偶尔),所以你可能需要将其注册为COM +组件(在我的经验)。这可能不会阻止内存泄漏,但它可以帮助prevent类未找到的错误。我不知道是什么原因发生在6.5

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