Someone asked why Admin rights are needed to debug SQL CLR Code?

The reason for this level of security is because debugging SQL CLR code stops all managed code on the server. So any process that is running on the server that calls managed code will be stopped. Essentially the server will be paused while the debugger is break mode. For this reason very high privileges are required to debug. We are trying to avoid accidental debugging of a server, there has to be a conscious effort on the user/admins part, to setup debugging.

This also means that SQL CLR debugging is really a single user scenario, since two people can not debug the same server at once.


With the release of Visual Studio 2005 Beta1 and SQL Server 2005 Beta2, lots of people have asked how to debug SQL CLR code / Managed SQL Assemblies.

This scenario assumes that you have Visual Studio 2005 Beta1 and SQL Server 2005 Beta2 installed on the same machine. Also you are logged in with Administrator rights.

  1. Start Visual Studio.
  2. Create a new C# SQL Server Project
  3. Add a reference to your SQL Server 2005 data base. Connect using Windows Authentication (Any DB will do ~ TempDB)
  4. Using the Solution Explorer create a new Stored Procedure. Context Menu-->Add New Item-->Stored Procedure
  5. Add some abitrary code. int i = 0; i++;
  6. Save, Build and Deploy the code.
  7. Place a BP in your new Stored Procedure.
  8. Enable SQL CLR debugging: Right click on the connection node in the Server Explorer and select Allow SQL/CLR debugging.
  9. From the debug menu choose Start F5

The BP should be hit, and your are successfully debugging SQL CLR code.