O'Reilly logo

ADO.NET Cookbook by Bill Hamilton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:

  1. Open the Server Explorer window in Visual Studio .NET by selecting it from the View menu.

  2. Create a connection to the database or select an existing connection.

  3. Select and expand the node for the database that contains the stored procedure.

  4. Expand the Stored Procedures node.

  5. Right-click on the stored procedure to be debugged and select Step Into Stored Procedure from the popup menu.

  6. 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:

  1. Right-click on the stored procedure to be debugged and select Step Into Stored Procedure from the popup menu.

  2. 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:

  1. Open the solution.

  2. In the Solution Explorer window, select the project and right-click. Select Properties from the popup menu.

  3. In the Property ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required