Archive for November 13th, 2007

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)