SQLTreeo T-SQL Debugger · How-to

Breakpoints and watches

Set breakpoints in a stored procedure or in the batch that calls it, give them a condition, and keep a few variables in view with watches.

SQLTreeo T-SQL Debugger stops a run where you tell it to. A breakpoint marks a statement, and a watch keeps a few variables in view while you step.

Set a breakpoint

Click in the left margin next to a line, or put the cursor on the line and press F9. A red dot marks the breakpoint. Breakpoints work in a procedure and in the batch in the Batch tab, which calls the procedure.

A breakpoint on a line without a statement, such as a comment or a blank line, moves to the next statement. It also moves with its line: when you add or remove lines above it in the editor, the breakpoint goes along.

Press F9 on the same line again to remove the breakpoint.

Give a breakpoint a condition

Open the Breakpoints tab, and enter a condition in the row of the breakpoint, such as @ItemId = 4. The debugger then stops there only when the condition is true, which saves a lot of stepping through a loop.

Pause when a variable changes

In the Breakpoints tab you can also add a variable that pauses the run when its value changes. Give it a condition, such as @n = 2, to pause only when the new value matches.

Watches

With dozens of variables, you want a few in view. Right-click a variable in the Variables pane and choose Add to watches, or select it and press the Add to watches button below the grid. The Watches tab opens with the variable in it.

  • A value that changed since the previous stop is shown in red.
  • You can also add an expression, such as @n * 2 or (SELECT COUNT(*) FROM #work). Expressions are evaluated at every stop, in the procedure the debugger is paused in.
  • Remove a watch with the Delete key, or from its right-click menu.

Stop and continue

Continue (F5) runs to the next breakpoint or the end. Into (F11), Over (F10) and Out (Shift+F11) step one statement at a time. Run from here continues at the line of the cursor.