Write a T-SQL query that filters records containing NCHAR(2028)

sql, sql-server, sql-server-2005, t-sql

Solution

Use a binary collation for your like comparison.

select * 
from tablename
where columnname COLLATE Latin1_General_Bin like '%' + NCHAR(2028) + '%'

Problem

My ultimate goal is to write a sql script that selects data from a particular table where a nvarchar(max) column contains the character NCHAR(2028). But the obvious: ``` select * from tablename where columnname like '%' + NCHAR(2028) + '%' ``` returns all rows.

Original source