Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

sp_unprepare (Transact-SQL)

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.

sp_unprepare handle         


Is the handle value returned by sp_prepare.

The following example prepares, and 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;

Community Additions

© 2015 Microsoft