SQL Server:如何检查是否启用了 CLR?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4804873/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SQL Server: How to check if CLR is enabled?
提问by magnattic
SQL Server 2008 - What is an easy way to check if clr is enabled?
SQL Server 2008 - 检查 clr 是否启用的简单方法是什么?
回答by Jason
SELECT * FROM sys.configurations
WHERE name = 'clr enabled'
回答by codingbadger
Check the config_value
in the results of sp_configure
检查config_value
结果sp_configure
You can enable CLR by running the following:
您可以通过运行以下命令启用 CLR:
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'clr enabled', 1;
GO
RECONFIGURE;
GO
回答by Larry Smith
The accepted answer needs a little clarification. The row will be there if CLR is enabled or disabled. Value will be 1 if enabled, or 0 if disabled.
接受的答案需要一些澄清。如果启用或禁用 CLR,该行将在那里。如果启用,则值为 1,如果禁用,则值为 0。
I use this script to enable on a server, if the option is disabled:
如果禁用该选项,我将使用此脚本在服务器上启用:
if not exists(
SELECT value
FROM sys.configurations
WHERE name = 'clr enabled'
and value = 1
)
begin
exec sp_configure @configname=clr_enabled, @configvalue=1
reconfigure
end
回答by Sayed Abolfazl Fatemi
The correct result for me with SQL Server 2017:
对我来说使用 SQL Server 2017 的正确结果:
USE <DATABASE>;
EXEC sp_configure 'clr enabled' ,1
GO
RECONFIGURE
GO
EXEC sp_configure 'clr enabled' -- make sure it took
GO
USE <DATABASE>
GO
EXEC sp_changedbowner 'sa'
USE <DATABASE>
GO
ALTER DATABASE <DATABASE> SET TRUSTWORTHY ON;
From An error occurred in the Microsoft .NET Framework while trying to load assembly id 65675
回答by grapefruitmoon
select *
from sys.configurations
where name = 'clr enabled'
回答by Mason Schmidgall
This is @Jason's answer but with simplified output
这是@Jason 的答案,但具有简化的输出
SELECT name, CASE WHEN value = 1 THEN 'YES' ELSE 'NO' END AS 'Enabled'
FROM sys.configurations WHERE name = 'clr enabled'
The above returns the following:
以上返回以下内容:
| name | Enabled |
-------------------------
| clr enabled | YES |
Tested on SQL Server 2017
在 SQL Server 2017 上测试