CLR
Common Language Runtime Assemblies
Common Language Runtime Assemblies
Enabling CLR allows the creation of CLR functions, stored procedures, triggers, user-defined aggregates and user-defined types.
- This is Disabled by default. Enable only if fully justified.
- If enabled, Permission should be set to SAFE_ACCESS (not EXTERNAL_ACCESS or UNSAFE)
- If enabled, the default Permission is SAFE. Change this Permission only if fully justified.
Check
Check
SELECT name,
CAST(value as int) as value_configured,
CAST(value_in_use as int) as value_in_use
FROM sys.configurations
WHERE name = 'clr enabled';
Both value columns will show 0 if CLR is disabled.
To check if CLR assemblies are in use...
USE [<database_name>]
GO
SELECT name AS Assembly_Name, permission_set_desc
FROM sys.assemblies
WHERE is_user_defined = 1;
GO
To check if Permission is set to SAFE_ACCESS...
SELECT name,
permission_set_desc
FROM sys.assemblies
WHERE is_user_defined = 1;
To set assemblies to SAFE use this code:
ALTER ASSEMBLY WITH PERMISSION_SET = SAFE;
Be aware that an alternate value is likely to have been set purposefully, so this change carries a risk that the assembly may cease to function as intended.
Disable
Disable
EXECUTE sp_configure 'clr enabled', 0;
RECONFIGURE;
Bibliography
Bibliography
https://docs.microsoft.com/en-us/sql/t-sql/statements/create-assembly-transact-sqlhttps://msdn.microsoft.com/en-us/library/ms345101(v=sql.100).aspx - CLR Integration Code Access Securityhttps://msdn.microsoft.com/en-us/library/ms345101(v=sql.105).aspx - CLR Integration Code Access Securityhttps://msdn.microsoft.com/en-us/library/ms189790(v=sql.100).aspx - sys.assemblies (Transact-SQL)https://msdn.microsoft.com/en-us/library/ms189790(v=sql.105).aspx - sys.assemblies (Transact-SQL)https://msdn.microsoft.com/en-us/library/ms186711(v=sql.100).aspx - ALTER ASSEMBLY (Transact-SQL)https://msdn.microsoft.com/en-us/library/ms186711(v=sql.105).aspx - ALTER ASSEMBLY (Transact-SQL)