加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

sql-server – 如何在不从SQL Server中删除程序集的情况下更新CL

发布时间:2020-12-12 16:46:26 所属栏目:MsSql教程 来源:网络整理
导读:如何在不必删除并在SQL Server(2008 R2)中重新创建程序集的情况下更新CLR函数(或过程)程序集dll? 现在,如果我更新程序集(例如添加新功能),SQL Server将不会遵循更新的dll,直到我删除程序集: DROP ASSEMBLY CLRFunctionsMsg 6590,Level 16,State 1,Line 1DRO
如何在不必删除并在SQL Server(2008 R2)中重新创建程序集的情况下更新CLR函数(或过程)程序集dll?

现在,如果我更新程序集(例如添加新功能),SQL Server将不会遵循更新的dll,直到我删除程序集:

DROP ASSEMBLY CLRFunctions

Msg 6590,Level 16,State 1,Line 1
DROP ASSEMBLY failed because 'CLRFunctions' is referenced by object 'NormalizeString'.

但在我放弃程序集之前,我必须首先删除引用它的所有函数:

DROP FUNCTION NormalizeString
DROP FUNCTION RemoveDiacritics
DROP FUNCTION RemoveCombiningDiacritics
DROP FUNCTION CombineLigatures
....
DROP FUNCTION PseudolocalizeArabic

然后我可以放弃大会:

DROP ASSEMBLY CLRFunctions

现在我必须“创建”程序集:

CREATE ASSEMBLY CLRFunctions FROM 'c:foosCLRFunctions.dll';

现在我必须在删除之前搜索已注册的所有UDF的声明.

我宁愿更新程序集,让SQL Server开始使用它.

更新:我随机尝试DBCC FREEPROCCACHE强制“重新编译”,但SQL Server仍然使用旧代码.

更新:我删除了程序集DLL CLRFunctions.dll,SQL Server仍然能够运行代码(没有代码应该是不可能的).

解决方法

我想你正在寻找改装装配.来自BOL:

If the FROM clause is specified,ALTER ASSEMBLY updates the assembly
with respect to the latest copies of the modules provided. Because
there might be CLR functions,stored procedures,triggers,data types,
and user-defined aggregate functions in the instance of SQL Server
that are already defined against the assembly,the ALTER ASSEMBLY
statement rebinds them to the latest implementation of the assembly.
To accomplish this rebinding,the methods that map to CLR functions,
stored procedures,and triggers must still exist in the modified
assembly with the same signatures. The classes that implement CLR
user-defined types and user-defined aggregate functions must still
satisfy the requirements for being a user-defined type or aggregate.

同一页面上的一个例子似乎就是这样做的:

ALTER ASSEMBLY ComplexNumber 
FROM 'C:Program FilesMicrosoft SQL Server90ToolsSamples1033EngineProgrammabilityCLRUserDefinedDataTypeCSComplexNumberobjDebugComplexNumber.dll'

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读