Using the Variables Window
Feature Only in Enterprise Edition SQL source code debugging is supported only in Visual C++ Enterprise Edition. For more information, see .
The Variables window provides quick access to variables that are important in the program’s current context.
The window includes three tabs:
The Auto tab displays variables used in the current statement and the previous statement. It also displays return values when you step over or out of a function.
The Locals tab displays the variables that are local to the current function.
The This tab displays the object pointed to by this. The this relates to the routine currently at the client-side debugger. It does not refer to the SQL Server.
Each tab contains a spreadsheet with fields for the variable name and value. The debugger automatically fills in these fields.
In addition to the tabs, the Variables window has a Context box on the toolbar. This box displays a list of the current Call Stack in a drop-down list box. You can select a context from this list to specify the current scope of the variables displayed.
Tip The Context box is part of a toolbar that you can hide using the right mouse button.
You can expand or collapse the displayed variables using the tree controls, but you cannot add variables to the Variables window. You can add variables in the Watch window.
When the program pauses at a breakpoint or between steps, you can change the value of any non-const local variable in your program. This gives you the flexibility to try out changes and see their results in real time or to recover from some logic error and continue.
Note Changes to local variables may not take effect while you’re stepping through the SQL statement. Although you may have modified the value, it may never be checked again. There is no way to force a refresh.
Tip The Variables window does not display variable type information, but you can show variable type information by using the window’s property page. Move the insertion point to a variable name in the Variables window, click the right mouse button, and then click Properties. The type, expression (variable), and value are displayed in the Program Variable Properties window.
To display the Variables window
From the View menu, click Debug Windows and Variables.
The Variables window appears.
Choose the Auto tab or Locals tab, according to the type of variables you want to see.
To view type information for a variable
In the Variables window, choose the Auto tab or Locals tab.
Select the line containing the variable whose type you want to see.
Click the right mouse button in the Variables window and click Properties from the shortcut menu.
– or –
From the View menu, click Properties.
Although you cannot delete variables from the Variables window, you can edit the values of local variables.
To modify the value of a variable
In the Variables window, choose the Auto tab or Locals tab.
Select the line containing the local variable you want to modify.
Double-click the value, or use the TAB key to move the insertion point to the value you want to modify.
Type the new value, and press ENTER.
Note You can modify only the following types of data: char, varchar, and integer data types. String variables (varchar) cannot be made longer.
Tip To change the value of strings, modify the individual characters.
Navigating From the Variables Window
You can navigate to SQL statements from the Context box in the Variables window. This box displays the SQL statements, if available, in a source window.
To navigate from the Variables window to SQL statements
- Select the SQL source name from the Context drop-down list box in the Variables window toolbar. For example, select the name of a stored procedure.
This procedure changes only the view of the program displayed in the Variables window and other debugger windows. It does not change the next line of execution or the value stored in the program counter.