SQL Server: IN ('asd') does not work when NTEXT column

How can I solve this problem?

where someNtext IN ('asd',asd1')

gives an error message:

Message 402, Level 16, State 1, String XXXXX
The ntext and varchar data types are not compatible in the equality operator.

+2
source share
3 answers

A list INis simply an abbreviation for OR conditions. Offer LIKEworks with NTEXTand fields TEXT. So you can combine these two ideas to do this:

WHERE (
       someNtext LIKE N'asd'
OR     someNtext LIKE N'asd1'
      )

, @marc_s , NVARCHAR(MAX) , ( TEXT, NTEXT IMAGE SQL Server 2005). , :

WHERE CONVERT(NVARCHAR(MAX), someNtext) IN (N'asd', N'asd1')

, , , LIKE OR.

: NVARCHAR NTEXT/NVARCHAR/NCHAR/XML NCHAR "N". , , .

/ /Unicode/ SQL Server, , : https://Collations.Info/

+5

http://msdn.microsoft.com/en-us/library/ms187993.aspx:

ntext, text Microsoft SQL Server. , . nvarchar (max), varchar (max) varbinary (max).

0

NText , , , nvarchar (MAX)

-1

All Articles