All essays
Blog Mayank Sanghvi April 13, 2024 1 min read 327 views 264 words

Execution of user code in the .NET Framework is disabled. Enable clr enabled configuration option

Step-by-Step Guide to Solve "Execution of user code in the .NET Framework is disabled. Enable "clr" enabled configuration option."Okay, so what's going on herunre? We are using the custom ".net" code within the SQL Server. We recently migra

Step-by-Step Guide to Solve "Execution of user code in the .NET Framework is disabled. Enable "clr" enabled configuration option."
Okay, so what's going on herunre? We are using the custom ".net" code within the SQL Server. We recently migrated our database to a new server. We encountered the above issue while trying to execute the old commands on the new server. As mentioned above, we moved our database to a new server, which is not ready to handle .net code. To fix the issue, we need to enable CLR. The following step-by-step command will help you enable CLR on your selected SQL Server database.

Please note that before enabling it, ensure all the ".net" assemblies used within the SQL Server are from a trusted source.

Don't enable "clr" for untrusted .net Assemblies.

As step one, we need to enable "clr" using the configuration. Execute the following command to perform the same.

Please note you may need special privileges to execute the commands. Also, please ensure you select the correct database before executing the command.


					USE DataBaseName
GO
EXEC sp_configure 'clr enabled', 1
GO

				

After executing the above command, you will get the following output.


					Configuration option 'clr enabled' changed from 0 to 1. Run the RECONFIGURE statement to install.
Completion time: 2024-04-13T19:13:12.9481831+05:30
				

As mentioned in the output, we must execute the "RECONFIGURE" command next. Please execute the following command as step 2.


					RECONFIGURE
GO
				

Output


					Commands completed successfully.
Completion time: 2024-04-13T19:19:09.5667460+05:30
				

We are using some custom .net code within SQL Server. We moved our database between different servers during one of our database migrations.


					EXEC sp_configure 'clr enabled'
GO

				
M
Mayank Sanghvi
Published April 13, 2024 · Updated November 13, 2024