Casey Crookston
Casey Crookston

Reputation: 13955

sp_executesql : Procedure expects parameter '@statement' of type 'ntext/nchar/nvarchar'

Here's what I am trying to do:

EXECUTE sp_executesql 
    'select * from AccessOrganizationSettings where OrganizationSys = @OrganizationSys', 
    N'@OrganizationSys nvarchar(250)', 
    @OrganizationSys = '805408'

But I get this error:

Procedure expects parameter '@statement' of type 'ntext/nchar/nvarchar'

Not sure what I am doing wrong.

Upvotes: 1

Views: 3032

Answers (1)

HoneyBadger
HoneyBadger

Reputation: 15140

As the error says, you need nvarchar rather than varchar. Try:

EXECUTE sp_executesql 
    N'select * from AccessOrganizationSettings where OrganizationSys = @OrganizationSys', 
    N'@OrganizationSys nvarchar(250)', 
    @OrganizationSys = N'805408'

The N makes the string an nvarchar datatype.

Upvotes: 4

Related Questions