sys.sp_prepexec
general #stored-procedure
Description
Prepares and executes a parameterized Transact-SQL statement. is a required parameter with an Identifies parameterized statements. The definition of variables is substituted for parameter markers in the statement. is a required parameter that calls for an value if the statement isn’t parameterized.
Syntax
sp_prepexec handle
OUTPUT
, params , stmt
[ , bound param ] [ ,.n ]
[ ; ]
Examples
Example 1
DECLARE
@
Out
AS
INT
;
EXECUTE sp_prepexec
@
Out
OUTPUT
, N
'@P1 nvarchar(128), @P2 nvarchar(100)'
,
N
'SELECT database_id, name
FROM sys.databases
WHERE name=@P1 AND state_desc = @P2'
,
@P1 =
'tempdb'
,
@P2 =
'ONLINE'
;
EXECUTE sp_unprepare @
Out
;