I am debugging some C# code that uses Ado.net to call a stored proc (TSQL) in SQL Server. How can I step into the stored proc?
(I think I have seen this demoed by Microsoft staff, but can’t recall the 101 “magic” settings that are needed to get it to work.)
Enable the SQL Server debugging in the project properties.
In Solution Explorer, right-click the project (not the solution) and open the Property pages. Click Configuration Properties in the tree and then click to select the SQL Server Debugging check box on the Debugging page to enable stored procedure debugging.
reference: http://support.microsoft.com/kb/316549
I'll build on Davide's answer and Ian's comment to it because that was the exactly the process I have gone through.
Assumption: answer is based on VS2008 & VS2010.
To step through a T-SQL stored procedure on SQL Server while debugging a .NET app you need to do the following:
Follow the MS Support instructions "How to debug stored procedures in Visual Studio .NET (Option 2)"
Enable the Allow SQL/CLR Debugging on the Data Connection on which the stored procedure is called:
Added from comments: (This seem to be key to getting it to work)
It works with a programmatically created connection, too. You just have to use the exact same connection string that is displayed when you right-click the server instance, click on 'Properties' and scroll down to 'Connection string' (Verbindungszeichenfolge in German).
For those of you who are using VS 2012 and are confused as to why you cannot enable SQL/CLR Debugging from the Server Explorer window, you actually need to connect via the "SQL Server Object Explorer" window.
Once you have the connection in that window, the
Allow SQL/CLR Debugging
andApplication Debugging
setting appear on the right-click context menu of your database. This probably applies to 2013 as well but I cannot confirm.