T-SQL and SQL CLR Debugging
Learn the magic key for enabling cross-process debugging.
April 19, 2004
Testing the Common Language Runtime (CLR) code for my example application was difficult until I discovered the new magic key for enabling cross-process debugging. The upcoming Visual Studio 2005 release includes an Attach to Process dialog box in the Debug menu, which replaces the Debug Process menu in Visual Studio .NET 2003. The Attach to Process dialog box links the Visual Studio 2005 IDE to the SQL Server running the stored procedure. For this example, I wanted to link to one of two SQL Servers—my development system was running both SQL Server 2000 Developer Edition and SQL Server 2005. The Attach to Process dialog box lists all the running processes, so you need to scroll down in the list to locate the sqlservr.exe process that shows the type SQL, .NET, Win32. (The SQL Server 2000 process doesn't include .NET in the type.) After you choose a process, click Attach to switch the IDE to run mode. Now, if you've set a breakpoint and the CLR stored procedure executes from the SQL Server Management Studio IDE, Visual Studio 2005 will break at the specified point—assuming the CLR logic gets to that point. Watch out—problems might occur if you wait too long in break mode because the server can timeout while waiting for the command to complete.
About the Author
You May Also Like