2014-11-07 11:48:00
DECLARE @sql NVARCHAR(MAX) = 'SET @count = ( SELECT * FROM sys.objects )' DECLARE @count INT EXEC sp_executeSQL @sql, N'@count INT OUTPUT', @count OUTPUT PRINT @count
Notes
The statement and parameter must be an NVARCHAR
or NCHAR
.
In this case @sql
is the statement parameter.
In this case N'@count INT OUTPUT'
is the parameter. Remember N
is the NVARCHAR attribute.