Watches are expressions that can be evaluated and displayed during a debugging session. The current values of the watch expressions are refreshed each time the debugger suspends execution. Watch expressions can be simple (i.e., a local variable or parameter) or complex such as an algebraic expression or a select statement.
If an expression returns a result set, the records returned display as child nodes in the Watches window.
Caution: The SELECT statement re-executes every time execution suspends (using steps or a halt). This may severely impact performance of the debugger if the query does not execute quickly or returns a large amount of data.
To add a watch from the Editor window
|»||Place the cursor in front of the variable or expression you want to watch and click on the Debugger toolbar.|
To add a watch from the Watches window
Select Debug | Windows | Watches from the menu.
Right-click anywhere in the window and select Add Watch.
Review the following for additional information:
Select one of the following watch scopes:
Enter or select an expression to use for the watch.
Note: This option is only available if you selected Automatic as the scope.
You can set an option so function calls are not evaluated in Tools | Options | Debugger | General.
When the current context changes, the Watches window evaluates the updated contents.
You can assign different values to a parameter or local variable by entering a value in the Watches window. This can be useful when testing a ”r;what if” scenario. However, this can affect the logic in the executing procedure.
Watches display in a tooltip in the Editor window when you place the cursor over an expression. In some cases, you may need to highlight the expression to evaluate more complicated expressions such as ”r;@x+10” or ”r;substring(@sVal, 1, 10)”.
Any execution on the database side that occurs in watches is executed on a different connection than the one being debugged. Pending transactions do not display in the result set.
When evaluating watches, if you start the watch with the word ”r;SELECT,” the watch is not evaluated. Instead, it is sent verbatim to the database server for evaluation using its syntax and only the parameters are replaced with actual values.
You can delete a watch by right-clicking it and selecting Delete Watch.