Debugging Database Objects That Use Managed Code (SQL Server CLR Integration Debugging)

Visual Studio 2010

This topic applies to:


Visual Basic



Web Developer


Topic does not applyTopic does not applyTopic does not applyTopic does not apply


Topic does not applyTopic does not applyTopic does not applyTopic does not apply

Pro and Team

Topic appliesTopic appliesTopic appliesTopic applies

Table legend:

Topic applies


Topic does not apply

Does not apply

Topic applies but command hidden by default

Command or commands hidden by default.

This section contains samples for all SQL Server Common Language Run-time (SQL CLR) database object types.

There are three different scenarios to consider:

To debug a trigger, you must start your debugging session in a stored procedure. In particular, you cannot debug a stand-alone Transact-SQL script, nor can you debug a trigger by causing it to fire by invoking a script.

SQL CLR debugging requires the following additional software on the server:

  • The Remote Debugging Monitor (msvsmon) must be running when you debug. If you are running SQL Server 2005, the Setup program to install msvsmon is already on the server, in <sql server install dir>\90\Shared\rdbgsetup.exe. Run this program to install it, and SQL Server will launch it whenever you step into or hit a breakpoint.

If, when you try to debug a SQL CLR object, the message "Canceled by user" appears, you must manually configure both the computer on which you are running Visual Studio as well as the computer that is running SQL Server. For more information, see How to: Configure Your Computers to Enable Transact-SQL and SQL Server CLR Integration Debugging.

Common Tasks

Supporting Content

Learn more about SQL CLR database projects: Read about advantages of developing.NET Framework database objects for SQL Server by using managed code. Managed code has several advantages compared with Transact-SQL.

Perform necessary setup before you debug: There are steps that you must take to enable SQL CLR debugging. In addition, you can find information about some common problems and how to resolve them.

Debug different types of SQL CLR objects: Follow the corresponding procedure to learn how to debug stored procedures, triggers, user-defined scalar functions, user-defined table-valued functions, user-defined aggregates, and user-defined types that were created by using managed code.

If you install a new version of after you complete the setup, you must rerun the Remote Components Setup to make sure that you have the correct components installed for remote debugging. For more information, see How to: Set Up Remote Debugging and [Obsolete] Remote Debugging Components.

When you try to start SQL debugging, you might receive the following error message: SQL Can't Find SSDEBUGPS.

To resolve this issue, you must rerun Remote Debugging Components. For more information, see How to: Set Up Remote Debugging.

The following error message might appear when you try to debug a SQL CLR object: Unable to attach to the crashing process. The specified program is not a Windows or MS-DOS program.

This error occurs when you manually launch the Remote Debugging Monitor (msvsmon) with SQL Server configured to run as an account other than LocalSystem or the user who is logged in.

To correct this error, you must allow SQL Server to auto-launch the Remote Debugging Monitor instead of launching it manually.



Debugging Transact-SQL (Microsoft Web site)

Describes how to debug database objects such as stored procedures, functions, and triggers.

Community Additions