Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

sp_unprepare (Transact-SQL)

Applies to: 👁 Image
SQL Server 👁 Image
Azure SQL Managed Instance 👁 Image
Azure Synapse Analytics 👁 Image
Analytics Platform System (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

Important

Arguments for extended stored procedures must be entered in the specific order as described in the Syntax section. If the parameters are entered out of order, an error message occurs.

handle

The handle value returned by sp_prepare. handle is int.

Examples

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

DECLARE @P1 AS INT;

EXECUTE 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';

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

EXECUTE sp_unprepare @P1;

Related content


Feedback

Was this page helpful?

Additional resources