SQL Server: How to check if CLR is enabled?

SqlSql ServerClr

Sql Problem Overview


SQL Server 2008 - What is an easy way to check if clr is enabled?

Sql Solutions


Solution 1 - Sql

SELECT * FROM sys.configurations
WHERE name = 'clr enabled'

Solution 2 - Sql

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

MSDN Article on enabling CLR

MSDN Article on sp_configure

Solution 3 - Sql

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

Solution 4 - Sql

select *
from sys.configurations
where name = 'clr enabled'

Solution 5 - Sql

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 https://stackoverflow.com/questions/8089112

Solution 6 - Sql

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionmagnatticView Question on Stackoverflow
Solution 1 - SqlJasonView Answer on Stackoverflow
Solution 2 - SqlcodingbadgerView Answer on Stackoverflow
Solution 3 - SqlLarry SmithView Answer on Stackoverflow
Solution 4 - SqlgrapefruitmoonView Answer on Stackoverflow
Solution 5 - SqlSayed Abolfazl FatemiView Answer on Stackoverflow
Solution 6 - Sqlspicy.dllView Answer on Stackoverflow