| title | sp_execute (Transact-SQL) | ||
|---|---|---|---|
| description | sp_execute executes a prepared Transact-SQL statement using a specified handle and optional parameter value. | ||
| author | markingmyname | ||
| ms.author | maghan | ||
| ms.reviewer | randolphwest | ||
| ms.date | 06/23/2025 | ||
| ms.service | sql | ||
| ms.subservice | system-objects | ||
| ms.topic | reference | ||
| f1_keywords |
|
||
| helpviewer_keywords |
|
||
| dev_langs |
|
||
| monikerRange | >=aps-pdw-2016 || =azure-sqldw-latest || >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current |
[!INCLUDE sql-asdbmi-asa-pdw]
Executes a prepared [!INCLUDE tsql] statement using a specified handle and optional parameter value. sp_execute is invoked by specifying ID = 12 in a tabular data stream (TDS) packet.
:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions
sp_execute handle OUTPUT
[ , bound_param ] [ , ...n ]
[ ; ]
[!INCLUDE extended-stored-procedures]
The handle value returned by sp_prepare. The required handle parameter is int, and can't be NULL.
Signifies the use of extra parameters. The bound_param parameter is any data type, to signify more parameters for the procedure, and can't be NULL.
Note
bound_param must match the declarations made by the sp_prepare @params value, and can be in the form @name = <value> or <value>.