| title | Specify a Breakpoint Action |
|---|---|
| titleSuffix | T-SQL debugger |
| description | Learn now to specify a What Hit action - a custom task for the Transact-SQL debugger to perform when a breakpoint is hit and certain other conditions are satisfied. |
| author | dzsquared |
| ms.author | drskwier |
| ms.reviewer | randolphwest |
| ms.date | 09/09/2025 |
| ms.service | sql |
| ms.subservice | ssdt |
| ms.topic | how-to |
[!INCLUDE SQL Server]
A breakpoint action specifies a custom task that the [!INCLUDE tsql] debugger performs for a breakpoint. If the specified hit count is reached and a specified breakpoint condition is satisfied, the debugger performs the action specified for the breakpoint.
The default action for a breakpoint is to break execution when both the hit count and breakpoint condition are satisfied. The primary use of an action in the [!INCLUDE tsql] debugger is to print information to the debugger Output window.
The message is specified in the Show a message in the Output Window: box, and is specified as a text string that includes expressions containing information from the [!INCLUDE tsql] being debugged. Expressions include:
-
A [!INCLUDE tsql] expression contained in curly braces (
{}). The expressions can include [!INCLUDE tsql] variables, parameters, and built-in functions. Examples include{@MyVariable},{@NameParameter},{@@SPID}, or{SERVERPROPERTY('ProcessID')}. -
One of the following keywords:
-
$ADDRESSreturns the name of the stored procedure or user-defined function where the breakpoint is set. If the breakpoint is set in the editor window,$ADDRESSreturns the name of the script file being edited.$ADDRESSand$FUNCTIONreturn the same information in the [!INCLUDE tsql] debugger. -
$CALLERreturns the name of the unit of [!INCLUDE tsql] code that called a stored procedure or function. If the breakpoint is in the editor window,$CALLERreturns<No caller available>. If the breakpoint is in a stored procedure or user-defined function called from the code in the editor window,$CALLERreturns the name of the file being edited. If the breakpoint is in a stored procedure or user-defined function called from another stored procedure or function,$CALLERreturns the name of the calling procedure or function. -
$CALLSTACKreturns the call stack of functions in the chain that called the current stored procedure or user-defined function. If the breakpoint is in the editor window,$CALLSTACKreturns the name of the script file being edited. -
$FUNCTIONreturns the name of the stored procedure or user-defined function where the breakpoint is set. If the breakpoint is set in the editor window,$FUNCTIONreturns the name of the script file being edited. -
$PIDand$PNAMEreturn the ID and name of the operating system process running the instance of the Database Engine where the [!INCLUDE tsql] is running.$PIDreturns the same ID asSERVERPROPERTY('ProcessID'), except that$PIDis a hexadecimal value whileSERVERPROPERTY('ProcessID')is a decimal value. -
$TIDand$TNAMEreturn the ID and name of the operating system thread running the [!INCLUDE tsql] batch. The thread is one associated with the process running the instance of the Database Engine.$TIDreturns the same value asSELECT kpid FROM sys.sysprocesses WHERE spid = @@SPID, except that$TIDis a hexadecimal value whilekpidis a decimal value.
-
-
You can also use the backslash character (
\) as an escape character to allow curly braces and backslashes in the message:\{,\}, and\\.
-
In the editor window, right-click the breakpoint glyph, and then select Actions on the shortcut menu.
-or-
In the Breakpoints window, right-click the breakpoint glyph, and then select Settings on the shortcut menu.
-
In the Breakpoint Settings dialog box, select the Actions option.
-
In the Show a message in the Output Window: dialog, enter an expression.
-
Select Continue code execution if you don't want the breakpoint to pause execution. This option is active only if you select the Actions option.
-
Select Close to implement the changes.