Output parameters and dynamic sql

I came across something new for the first time today. Dynamic SQL with output parameters.

Here is how you do it in MSSQL.

DECLARE @totals INT
EXEC sp_executesql N’SELECT @totalCount = count(*) from sysobjects’, N’@totalCount INT OUTPUT’, @totals OUTPUT
print ‘Totals: ‘ + convert(varchar,@totals)

You can leave a response, or trackback from your own site.

Leave a Reply