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
Tuesday, December 23, 2003 7:44 PM