SQL Server 2008 - What is an easy way to check if clr is enabled?
Asked
Active
Viewed 1.3e+01k times
6 Answers
149
SELECT * FROM sys.configurations
WHERE name = 'clr enabled'

Jason
- 4,557
- 5
- 31
- 40
-
31Additional Note : Value will be 1 if enabled, or 0 if disabled. – Muthukumar May 10 '14 at 17:45
-
This is still valid in SQL 2016. – Rashack Apr 16 '19 at 07:06
38
Check the config_value
in the results of sp_configure
You can enable CLR by running the following:
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'clr enabled', 1;
GO
RECONFIGURE;
GO

codingbadger
- 42,678
- 13
- 95
- 110
-
6I don't think you should actually configure the option just to check if it's configured! I realize it will say `was 0 now 1`, or similar, but ... – Josh M. Apr 17 '14 at 20:11
29
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.
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

Larry Smith
- 1,863
- 16
- 15
-
1EXISTS() is slightly faster than NOT EXISTS(). Just a friendly note. ;) – clifton_h Apr 26 '17 at 14:02
-
4in this case imho readability trumps performance, which for a single shot dba usage like this would be infinitesimal. – Larry Smith May 10 '17 at 17:33
3
The correct result for me with 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

halfer
- 19,824
- 17
- 99
- 186

Sayed Abolfazl Fatemi
- 3,678
- 3
- 36
- 48
2
This is @Jason's answer but with simplified output
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

spicy.dll
- 948
- 8
- 23