This topic demonstrates how to debug a Transact‑SQL trigger by setting breakpoints, stepping through code, and inspecting variable values.
Use the sample scripts to create the dbo.trg_ScheduleDetail_Insert trigger in the TestScheduleDB database.
1. In Database Explorer, right-click the required database and select New SQL to open a SQL document.
2. Type the following SQL statement:
INSERT INTO dbo.ScheduleDetail (ScheduleId, DateOut, TimeSheetDate, AbsenceCode) VALUES (11, '2025-07-01', '2025-07-01', NULL);
3. To start debugging, on the Debug toolbar, click
Step Into or press F11 until a SQL document with the CREATE statement for the trigger opens.
Alternatively, in the top menu, select Debug > Step Into.

Note
The yellow arrow identifies the stack frame where the execution pointer is currently located.
4. Optional: To view the variable value, hover over it in the query.
The quick info tip will be displayed.

Note
Ensure the Enable code completion feature is selected in Tools > Options > Text Editor > Code Completion > General.
5. To insert a breakpoint, do one of the following:
In the SQL Editor, the line with the breakpoint will be highlighted in red.

6. On the Debug toolbar, click
, or press Alt+F5.
The Breakpoints pane opens where you can view and manage breakpoints.
7. To add the variable to the Watches pane, right-click the variable, then select Add Watch.

8. On the Debug toolbar, click
, or press Alt+F5.
Alternatively, click
or press F11 repeatedly to step through the trigger.
9. To stop debugging, do one of the following:
In the top menu, select Debug > Stop Debugging or press Shift+F5.
On the Debugger toolbar, click
.