9.8. Debugging a SQL Server Stored Procedure
Problem
Given an application that uses a SQL Server stored procedure that is causing errors, you need to debug the stored procedure.
Solution
Use Visual Studio .NET to debug SQL Server stored procedures (in both standalone mode and from managed code).
Discussion
Debugging a stored procedure in standalone mode
You can debug a stored procedure in standalone mode from Visual Studio .NET Server Explorer by following these steps:
Open the Server Explorer window in Visual Studio .NET by selecting it from the View menu.
Create a connection to the database or select an existing connection.
Select and expand the node for the database that contains the stored procedure.
Expand the Stored Procedures node.
Right-click on the stored procedure to be debugged and select Step Into Stored Procedure from the popup menu.
If requested, supply the parameter values on the Run Stored Procedure dialog.
Alternatively, if the stored procedure is already open in a source window in Visual Studio .NET:
Right-click on the stored procedure to be debugged and select Step Into Stored Procedure from the popup menu.
If requested, supply the parameter values on the Run Stored Procedure dialog.
Debugging a stored procedure from managed code
To debug a stored procedure from managed code, SQL debugging must be enabled for the project. Follow these steps:
Open the solution.
In the Solution Explorer window, select the project and right-click. Select Properties from the popup menu.
In the Property ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access