sp_unprepare (Transact-SQL)

APPLIES TO: yesSQL Server noAzure SQL Database yesAzure SQL Data Warehouse yesParallel Data Warehouse

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

-- Syntax for SQL Server, Azure SQL Data Warehouse, Parallel Data Warehouse  
  
sp_unprepare handle           

Arguments

handle
Is the handle value returned by sp_prepare.

Examples

The following example prepares, executes, and unprepares a simple 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;  

Examples: Azure SQL Data Warehouse and Parallel Data Warehouse

The following example prepares, executes, and unprepares a simple 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;  

See Also

sp_prepare (Transact SQL)