I faced problem when I called sp_executesql
and I passed varchar parameter.
I got this error:
Procedure expects parameter '@statement' of type 'ntext/nchar/nvarchar'.
I faced problem when I called sp_executesql
and I passed varchar parameter.
I got this error:
Procedure expects parameter '@statement' of type 'ntext/nchar/nvarchar'.
This means the
@statement
parameter ofsp_executesql
expectsnvarchar
.This does not mean that your parameter has to be nvarchar.
Of course, if you don't have parameters, why are you using sp_executesql?
Psychic debugger says you either are passing to
SP_ExecuteSQL
a variable of type varchar (make it nvarchar), or you've got a string you haven't used the unicode prefix on:E.g.
To fix it use:
Notice the
N
prefix on the string.Try this :
e.g. This will give the error because @SQL needs to be NVARCHAR
Below give error:
So: Use
NVARCHAR(100)