Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to:
SQL Server
A breakpoint action specifies a custom task that the Transact-SQL 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.
Action considerations
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 Transact-SQL 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 Transact-SQL being debugged. Expressions include:
A Transact-SQL expression contained in curly braces (
{}). The expressions can include Transact-SQL 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 Transact-SQL debugger.$CALLERreturns the name of the unit of Transact-SQL 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 Transact-SQL 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 Transact-SQL 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\\.
Specify an action
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.