A prepare and execute example. It prepares a statement with one variable (@P1). The returned handle (@H1) is executed.
-- Prepare statement... DECLARE @H1 int EXEC sp_prepare @H1 OUTPUT, N'@P1 nvarchar(25)', N'SELECT @P1 AS StmtExecute', 1 --SELECT @H1 -- Execute handle... EXEC sp_execute @H1, N'Succes' -- Unprepare statement... EXEC sp_unprepare @H1