What’s the right way to compare an NTEXT column with a constant value?

The ntext data type is deprecated in favour of the nvarchar(max) data type. If you can change the data type in the table, that would be the best solution. Then there is no problem comparing it to a varchar literal.

Otherwise you would have to cast the value before comparing it:

cast([ntext2] as nvarchar(max)) <> '1,032.5'

You might also consider using a nvarchar literal, which solves some similar data type problems:

cast([ntext2] as nvarchar(max)) <> N'1,032.5'

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)