I’m having an issue with this procedure.
Here’s the code
declare @sql nvarchar(4000)
set @sql = N'SELECT @resp2 = count(*) from '+ @NameTable + ' where datum = ''1'' or datum = ''2'' '
EXEC sp_executesql
@query = @sql,
@params = N'@resp2 INT OUTPUT',
@resp2 = @resp2 OUTPUT
“Procedure expects parameter ‘@statement’ of type
‘ntext/nchar/nvarchar’.”
Am I not giving the statement? (@sql)
All I want to do is set a value to @resp2 in the execution.
According to the manual, you should provide a value for the parameter called
@statement, but you are supplying it as@query.So it should be:
Just follow the manual, and you’ll be okay.