Saturday, 17 November 2018

MS SQL - Fix Error - Procedure expects parameter '@statement' of type 'ntext/nchar/nvarchar'.


Watch this example on YouTube


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

To fix it replace

Declare @SomeText varchar(max) = '1,2,3'
Declare @SQL varchar(max) = 'Select Count (*) from TableTest Where ID in (' + @SomeText + ')'
Exec sp_executesql @SQL

with

Declare @SomeText varchar(max) = '1,2,3'
Declare @SQL nvarchar(max) = 'Select Count (*) from TableTest Where ID in (' + @SomeText + ')'
Exec sp_executesql @SQL

3 comments:

  1. DECLARE @input VARCHAR(256) = 'LIFE HAS NO LIMITATIONS EXCEPT THE ONCE YOU MAKE'
    SELECT STRING_AGG(UPPER(LEFT(Value,1)) + RIGHT(Value,DATALENGTH(Value) - 1),' ')
    FROM string_split(LOWER(@input),' ');

    CAN ANY BODY GIVE A SOLUTION

    ERROR
    Msg 536, Level 16, State 2, Line 33
    Invalid length parameter passed to the RIGHT function.

    ReplyDelete
  2. when the text has single space its allowing , when goes with double space getting error

    ReplyDelete
  3. the parameterized query '(@status nvarchar(7),@namear nvarchar(26),@nameen nvarchar(28),@' expects the parameter '@rejectionletterar', which was not supplied.
    How can I fix this

    ReplyDelete