ОБЛАСТЬ ПРИМЕНЕНИЯ:
SQL Server
База данных SQL Azure (только управляемый экземпляр)
Azure Synapse Analytics (хранилище данных SQL)
Parallel Data Warehouse APPLIES TO:
SQL Server
Azure SQL Database (Managed Instance only)
Azure Synapse Analytics (SQL DW)
Parallel Data Warehouse
Функция интеграции со средой CLR отключена по умолчанию, поэтому ее нужно включить, чтобы использовать объекты, использующие интеграцию со средой CLR. The common language runtime (CLR) integration feature is off by default, and must be enabled in order to use objects that are implemented using CLR integration. Чтобы включить интеграцию со средой CLR, используйте параметр clr enabled хранимой процедуры sp_configure в SQL Server Management Studio SQL Server Management Studio : To enable CLR integration, use the clr enabled option of the sp_configure stored procedure in SQL Server Management Studio SQL Server Management Studio :
Вы можете отключить интеграцию со средой CLR, задав для параметра clr enabled значение 0. You can disable CLR integration by setting the clr enabled option to 0. При отключении интеграции со средой CLR SQL Server SQL Server останавливает выполнение всех определяемых пользователем подпрограмм CLR и выгружает все домены приложений. When you disable CLR integration, SQL Server SQL Server stops executing all user-defined CLR routines and unloads all application domains. Этот параметр не влияет на функции, зависящие от среды CLR, например тип данных hierarchyid , функцию FORMAT , репликацию и управление на основе политик, и будет продолжать функционировать. Features that rely upon the CLR, such as the hierarchyid data type, the FORMAT function, replication, and Policy-Based Management, are not affected by this setting and will continue to function.
Чтобы включить интеграцию со средой CLR, необходимо иметь разрешение ALTER SETTINGS на уровне сервера, которое неявно удерживается членами предопределенных ролей сервера sysadmin и serveradmin . To enable CLR integration, you must have ALTER SETTINGS server level permission, which is implicitly held by members of the sysadmin and serveradmin fixed server roles.
Компьютеры, сконфигурированные для работы с большим объемом памяти и большим числом процессоров, при запуске сервера могут отказаться загружать функцию интеграции со средой CLR SQL Server. Computers configured with large amounts of memory and a large number of processors may fail to load the CLR integration feature of SQL Server when starting the server. Чтобы устранить эту неполадку, запустите сервер с помощью параметра запуска службы gmemory_to_reserve SQL Server SQL Server и укажите достаточно большое значение памяти. To address this issue, start the server by using the -gmemory_to_reserve SQL Server SQL Server service startup option, and specify a memory value large enough. Дополнительные сведения см. в разделе Параметры запуска службы Database Engine. For more information, see Database Engine Service Startup Options.
Выполнение в среде CLR не поддерживается при использовании упрощенных пулов. Common language runtime (CLR) execution is not supported under lightweight pooling. Перед включением интеграции со средой CLR необходимо отключить функцию использования упрощенных пулов. Before enabling CLR integration, you must disable lightweight pooling. Дополнительные сведения см. в разделе Параметр конфигурации сервера «использование упрощенных пулов». For more information, see lightweight pooling Server Configuration Option.
ОБЛАСТЬ ПРИМЕНЕНИЯ:
SQL Server
База данных SQL Azure
Azure Synapse Analytics (хранилище данных SQL)
Parallel Data Warehouse APPLIES TO:
SQL Server
Azure SQL Database
Azure Synapse Analytics (SQL DW)
Parallel Data Warehouse
Используйте параметр «clr enabled», чтобы указать, может ли SQL Server SQL Server выполнять пользовательские сборки. Use the clr enabled option to specify whether user assemblies can be run by SQL Server SQL Server . Параметр clr enabled принимает перечисленные ниже значения. The clr enabled option provides the following values:
| Значение Value | Описание Description |
|---|---|
| 0 0 | Выполнение сборок не разрешается в SQL Server SQL Server . Assembly execution not allowed on SQL Server SQL Server . |
| 1 1 | Выполнение сборок разрешается в SQL Server SQL Server . Assembly execution allowed on SQL Server SQL Server . |
Только в WOW64. WOW64 only. Перезагрузите серверы WOW64, чтобы изменения параметров вступили в силу. Restart WOW64 servers to effect the settings changes. Для других типов серверов перезагрузка не требуется. No restart required for other server types.
При выполнении инструкции RECONFIGURE и изменении значения параметра clr enabled с 1 на 0 все домены приложений, содержащие пользовательские сборки, немедленно выгружаются. When you run RECONFIGURE, and the run value of the clr enabled option is changed from 1 to 0, all application domains containing user assemblies are immediately unloaded.
При использовании упрощенных пулов выполнение в среде CLR не поддерживается. Отключите параметр «clr enabled» или «lightweight pooling». Common language runtime (CLR) execution is not supported under lightweight pooling Disable one of two options: «clr enabled» or «lightweight pooling». Функции, зависящие от среды CLR и неправильно работающие в режиме волокон, включают тип данных hierarchyid, функцию FORMAT , репликацию и управление на основе политик. Features that rely upon CLR and that do not work properly in fiber mode include the hierarchyid data type, the FORMAT function, replication, and Policy-Based Management.
Среда CLR использует управление доступом для кода (CAS) в .NET Framework, которое больше не поддерживается в качестве границы безопасности. CLR uses Code Access Security (CAS) in the .NET Framework, which is no longer supported as a security boundary. Сборки среды CLR, созданные с помощью PERMISSION_SET = SAFE , могут получать доступ к внешним системным ресурсам, вызывать неуправляемый код и получать права системного администратора. A CLR assembly created with PERMISSION_SET = SAFE may be able to access external system resources, call unmanaged code, and acquire sysadmin privileges. Начиная с SQL Server 2017 (14.x) SQL Server 2017 (14.x) , появился параметр sp_configure , называемый clr strict security , для повышения безопасности сборок среды CLR. Beginning with SQL Server 2017 (14.x) SQL Server 2017 (14.x) , an sp_configure option called clr strict security is introduced to enhance the security of CLR assemblies. clr strict security включен по умолчанию и рассматривает сборки SAFE и EXTERNAL_ACCESS , как если бы они были помечены UNSAFE . clr strict security is enabled by default, and treats SAFE and EXTERNAL_ACCESS assemblies as if they were marked UNSAFE . Параметр clr strict security можно отключить для обеспечения обратной совместимости, но это делать не рекомендуется. The clr strict security option can be disabled for backward compatibility, but this is not recommended. Корпорация Майкрософт рекомендует подписывать все сборки с помощью сертификата или асимметричного ключа с соответствующим именем входа, которому предоставлено разрешение UNSAFE ASSEMBLY в базе данных master. Microsoft recommends that all assemblies be signed by a certificate or asymmetric key with a corresponding login that has been granted UNSAFE ASSEMBLY permission in the master database. Администраторы SQL Server SQL Server также могут добавлять сборки в список сборок, которым должно доверять ядро СУБД. SQL Server SQL Server administrators can also add assemblies to a list of assemblies, which the Database Engine should trust. Дополнительные сведения см. в разделе sys.sp_add_trusted_assembly. For more information, see sys.sp_add_trusted_assembly.
Пример Example
В следующем примере сначала отображается текущая настройка параметра clr enabled, а затем параметр включается с заданием значения 1. The following example first displays the current setting of the clr enabled option and then enables the option by setting the option value to 1. Чтобы отключить этот параметр, задайте значение 0. To disable the option, set the value to 0.
SQL Server 2008 — What is an easy way to check if clr is enabled?

6 Answers 6

Check the config_value in the results of sp_configure
You can enable CLR by running the following:
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: