Skip to content

Latest commit

 

History

History
59 lines (43 loc) · 1.46 KB

sp-unprepare-transact-sql.md

File metadata and controls

59 lines (43 loc) · 1.46 KB
title description author ms.author ms.reviewer ms.date ms.service ms.subservice ms.topic f1_keywords helpviewer_keywords dev_langs monikerRange
sp_unprepare (Transact-SQL)
Discards the execution plan created by the `sp_prepare` stored procedure.
markingmyname
maghan
randolphwest
03/07/2025
sql
system-objects
reference
sp_cursor_unprepare_TSQL
sp_cursor_unprepare
sp_unprepare
TSQL
>=aps-pdw-2016 || =azure-sqldw-latest || >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current

sp_unprepare (Transact-SQL)

[!INCLUDE sql-asdbmi-asa-pdw]

Discards the execution plan created by the sp_prepare stored procedure. sp_unprepare is invoked by specifying ID = 15 in a tabular data stream (TDS) packet.

Syntax

sp_unprepare handle
[ ; ]

Arguments

[!INCLUDE extended-stored-procedures]

handle

The handle value returned by sp_prepare. handle is int.

Examples

The following example prepares, executes, and unprepares a basic statement.

DECLARE @P1 INT;

EXEC sp_prepare @P1 OUTPUT,
    N'@P1 NVARCHAR(128), @P2 NVARCHAR(100)',
    N'SELECT database_id, name FROM sys.databases WHERE name = @P1 AND state_desc = @P2';

EXEC sp_execute @P1, N'tempdb', N'ONLINE';

EXEC sp_unprepare @P1;

Related content