title: "Specify a Breakpoint Action | Microsoft Docs" ms.custom: "" ms.date: "03/14/2017" ms.prod: "sql" ms.prod_service: "sql-tools" ms.service: "" ms.component: "ssms-scripting" ms.reviewer: "" ms.suite: "sql" ms.technology:
- "database-engine" ms.tgt_pltfrm: "" ms.topic: "article" f1_keywords:
- "vs.debug.breakpt.action" helpviewer_keywords:
- "Transact-SQL debugger, breakpoint action"
- "Transact-SQL debugger, breakpoint when hit action" ms.assetid: f97f0097-6f51-40c1-b2e0-294a93ce1e1b caps.latest.revision: 10 author: "MightyPen" ms.author: "genemi" manager: "craigg" ms.workload: "Inactive" monikerRange: ">= aps-pdw-2016 || = azuresqldb-current || = azure-sqldw-latest || >= sql-server-2016 || = sqlallproducts-allversions"
[!INCLUDEappliesto-ss-asdb-asdw-pdw-md] A breakpoint When Hit action specifies a custom task that the [!INCLUDEtsql] debugger performs for a breakpoint. If the specified hit count is reached and any 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 have been satisfied. The primary use of a When Hit action in the [!INCLUDEtsql] debugger is to instead print information to the debugger Output window by specifying a print message.
A print message is specified in the Print a Message option, and is specified as a text string that includes expressions containing information from the [!INCLUDEtsql] being debugged. Expressions include:
-
A [!INCLUDEtsql] expression contained in curly braces ({}). The expressions can include [!INCLUDEtsql] variables, parameters, and built-in functions. Examples include {@MyVariable}, {@NameParameter}, {@@SPID}, or {SERVERPROPERTY(‘ProcessID’)}.
-
One of the following keywords:
-
$ADDRESS returns the name of the stored procedure or user-defined function where the breakpoint is set. If the breakpoint is set in the editor window, $ADDRESS returns the name of the script file being edited. $ADDRESS and $FUNCTION return the same information in the [!INCLUDEtsql] debugger.
-
$CALLER returns the name of the unit of [!INCLUDEtsql] code that called a stored procedure or function. If the breakpoint is in the editor window, $CALLER returns <No caller available>. If the breakpoint is in a stored procedure or user-defined function called from the code in the editor window, $CALLER returns 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, $CALLER returns the name of the calling procedure or function.
-
$CALLSTACK returns 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, $CALLSTACK returns the name of the script file being edited.
-
$FUNCTION returns the name of the stored procedure or user-defined function where the breakpoint is set. If the breakpoint is set in the editor window, $FUNCTION returns the name of the script file being edited.
-
$PID and $PNAME return the ID and name of the operating system process running the instance of the Database Engine where the [!INCLUDEtsql] is running. $PID returns the same ID as SERVERPROPERTY(‘ProcessID’), except that $PID is a hexadecimal value while SERVERPROPERTY(‘ProcessID’) is a decimal value.
-
$TID and $TNAME return the ID and name of the operating system thread running the [!INCLUDEtsql] batch. The thread is one associated with the process running the instance of the Database Engine. $TID returns the same value as SELECT kpid FROM sys.sysprocesses WHERE spid = @@SPID, except that $TID is a hexadecimal value while kpid is 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 click When Hit on the shortcut menu.
-or-
In the Breakpoints window, right-click the breakpoint glyph, and then click When hit on the shortcut menu.
-
In the When Breakpoint Is Hit dialog box, select the behavior you want:
-
Select Print a Message to print a message in the debugger Output window when the breakpoint is hit.
-
The Run a Macro option is not available from the [!INCLUDEtsql] debugger, and is greyed out.
-
Select Continue execution if you do not want the breakpoint to pause execution. This option is active only if you have selected the Print a Message option.
-
-
Click OK to implement the changes, or Cancel to exit without applying the changes.