Home Forums SQL Server 2005 T-SQL (SS2K5) getting in error in using sp_executesql like Procedure expects parameter '@statement' of type 'ntext/nchar/nvarchar' RE: getting in error in using sp_executesql like Procedure expects parameter '@statement' of type 'ntext/nchar/nvarchar'

  • You're using the wrong datatype...

    From BOL:

    [ @stmt = ] stmt

    Is a Unicode string that contains a Transact-SQL statement or batch. stmt must be either a Unicode constant or a variable that can be implicitly converted to ntext. More complex Unicode expressions, such as concatenating two strings with the + operator, are not allowed. Character constants are not allowed. If a constant is specified, it must be prefixed with an N. For example, the Unicode constant N'sp_who' is valid, but the character constant 'sp_who' is not. The size of the string is limited only by available database server memory.

    -- end BOL --

    Change this row:

    DECLARE @SQL VARCHAR(1000)

    to

    DECLARE @SQL NVARCHAR(1000)

    /Kenneth