How to: Step into an Object Using Server Explorer
This topic applies to:
Edition |
Visual Basic |
C# |
C++ |
Web Developer |
---|---|---|---|---|
Express |
||||
Standard |
||||
Pro and Team |
Table legend:
Applies |
|
Does not apply |
|
Command or commands hidden by default. |
The following procedure describes how to debug a database object by stepping into it with the Visual Studio Server Explorer. This method of SQL debugging is known as Direct Database Debugging, and can be done in Visual Studio outside of any project if need be. You can step into stored procedures and user-defined functions (UDFs). To debug any other object, you must reference it from a stored procedure or UDF, or cause it to fire, in the case of triggers, and start debugging by stepping into the procedure or function.
To step into an object by means of Server Explorer
In Visual Studio, if you have not already done so, establish a connection to the database. For more information, see How to: Connect to a Database.
If the object is written in C# or Visual Basic, verify SQL CLR debugging is enabled for the connection. For more information, see How to: Enable CLR Debugging For a Connection.
In Server Explorer, find the name of the object to be debugged by opening the database node, and then the appropriate folder. Double-click the object's file name to load the code into the Text Editor.
Right-click the object name, and on the shortcut menu, click Step into <object type> to step into the object with the debugger.
- If the object is a trigger, you cannot step into it directly; instead, you must step into a stored procedure that can cause the trigger to fire.
If the object requires parameters, a dialog box appears, with a table containing a row for each parameter. Each row in the table contains a column for the name of the parameter, and one for the value of that parameter. Enter values for each parameter, and click OK.
The code for the object is displayed, with a yellow arrow in the left gray margin indicating the statement about to be executed. The instruction pointer will be on the first executable line of code in the object.
You may now use most of the familiar debugger features. For more information see SQL Object Debugging Using the Locals and Watch Windows and Limitations on Debugger Commands and Features.
To continue debugging, on the Debug menu, click Continue. The code executes up to the next breakpoint.