I recently converted all ntext column types in my database to nvarchar(max). I then ran EXECUTE sp_refreshview for the related views.
Yet when I run the following Parameter query (from classic ASP) on a view, I get an error: Query:
SELECT CARID
FROM vwCAR
WHERE (1=1)
AND (Description LIKE '%'+ ? + '%')
ORDER BY CARID;
Error: The data types nvarchar and ntext are incompatible in the add operator (yet there are no longer any ntext columns!)
Yet I do NOT get this error if I run the same query directly SQL Server without the ? parameter as: Query:
SELECT CARID
FROM vwCAR
WHERE (1=1)
AND (Description LIKE '%test%')
ORDER BY CARID;
I tried using Convert in the query, but had same result: Query:
SELECT CARID
FROM vwCAR
WHERE (1=1)
AND (CONVERT(NVARCHAR(MAX), Description) LIKE N'%'+ ? + '%')
ORDER BY CARID;
What am I doing wrong?
Additional information: I changed the type to nVarChar(4000) instead of (MAX) and everything works fine. This is a work around, but it solved the problem.
Just so I will know for the future, is it possible to run a parameter query using LIKE criteria on a nVarChar(Max) type column?
(Thank you @McNets for the post clean up .. I am new to this)