在SQL Server 2008-r2上启用CLR集成

时间:2012-11-09 11:15:36

标签: sql-server sql-server-2008 configuration sql-server-2008-r2 sqlclr

寻找启用CLR集成我发现这个文档:http://msdn.microsoft.com/en-us/library/ms131048.aspx表示使用以下代码将“crl enabled”变量设置为1。

sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'clr enabled', 1;
GO
RECONFIGURE;
GO

我想知道如果需要重新启动SQL Server?或者,更具体地说,为了启用CRL集成,要遵循哪些步骤?

2 个答案:

答案 0 :(得分:8)

如果使用with override选项,则不需要重启。

EXEC sp_CONFIGURE 'show advanced options' , '1';
GO
RECONFIGURE WITH OVERRIDE
GO

EXEC sp_CONFIGURE 'clr enabled' , '1'
GO
RECONFIGURE WITH OVERRIDE
GO

答案 1 :(得分:6)

接受的答案不正确。 WITH OVERRIDE的{​​{1}}选项与是否需要重新启动SQL Server完全无关。 RECONFIGURE的MSDN文档指出RECONFIGURE

  

禁用配置值检查(对于无效值或非推荐值的值)...

事实是,WITH OVERRIDE中启用或禁用“CLR集成”选项时,不需要重新启动SQL Server服务。一个简单的测试(在SQL Server 2008 R2上运行,但在支持SQLCLR的所有版本中运行相同)证明了这一点:

sp_configure

结果:

注意EXEC sp_configure 'clr enabled'; -- show current value EXEC sp_configure 'clr enabled', 0; RECONFIGURE; EXEC sp_configure 'clr enabled'; -- show current value GO EXEC sp_configure 'clr enabled'; -- show current value EXEC sp_configure 'clr enabled', 1; RECONFIGURE; EXEC sp_configure 'clr enabled'; -- show current value GO 字段。它从“1”开始,因为我的系统已经启用了“CLR集成”。但只需调用run_value即可切换。

RECONFIGURE

此外,还应说明问题中所示的初始代码,

的陈述
name          minimum   maximum   config_value   run_value
clr enabled   0         1         1              1

clr enabled   0         1         0              0

clr enabled   0         1         0              0

clr enabled   0         1         1              1

是不必要的,因为sp_configure 'show advanced options', 1; 不是高级选项。

要证明关于clr enabled不是高级选项的观点,甚至显示另一种方法来证明此选项不需要重新启动,只需执行以下简单查询:

clr enabled

正如您在上面显示的结果集中看到的那样,SELECT [name], [value], [value_in_use], [is_dynamic], [is_advanced] FROM sys.configurations WHERE [configuration_id] = 1562; /* name value value_in_use is_dynamic is_advanced clr enabled 1 1 1 0 */ is_advanced,意思是“不是高级选项(是的,官方Microsoft文档目前不正确;我会在有时更新它此外,0is_dynamic,这意味着只需执行1即可立即启用该选项,而无需重新启动实例。

总结:启用“CLR集成”并且无需重新启动SQL Server服务所需的所有步骤的总和如下:

RECONFIGURE

就是这样。 **

** WOW64服务器 需要重启服务器才能使此选项生效。 (clr enabled Server Configuration Option