Anatoly Lubarsky Logo
MSSQL, .NET, Design. Life and Music

T-SQL: Output Parameter in sp_executesql

sp_executesql is MSSQL system procedure used to execute dynamic SQL (SQL string built dynamically). Sometimes there is a need to return output parameter from that dynamic SQL. Below is a small T-SQL code snippet that demonstrates how to do it.


DECLARE @i INT
EXEC sp_executesql N'SELECT @i = 1', N'@i INT OUTPUT', @i OUTPUT
SELECT @i

Related Posts:

Tuesday, December 23, 2003 7:44 PM

Comments

# re: Output parameter from sp_executesql N'
Thanx for your tip, helps well....

12/2/2004 9:28 AM by Jaroslav Urban

If your feedback doesn't appear right away, please be patient as it may take a few minutes to publish.

Post a Comment

Protected by CAPTCHAEnter the code you see
Name (*)  
E-mail (*)  
Url
Remember

Comment (*)