Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Querying a SQL Server 2008 table to find values in a column containing Unicode characters

I've run into a problem in a project I'm working on: some of the string values in a specific SQL Server 2008 table column contain Unicode characters. For example, instead of a dash some strings will instead contain an EM DASH (http://www.fileformat.info/info/unicode/char/2014/index.htm).

The column values that contain Unicode characters are causing problems when I send HTTP requests to a third-party server. Is there a way to query what rows contain one-or-more Unicode characters, so I can at least begin to identify how many rows need to be fixed?

like image 405
Mass Dot Net Avatar asked Dec 02 '22 03:12

Mass Dot Net


1 Answers

You want to find all strings that contain one or more characters outside ASCII characters 32-126.

I think this should do the job.

SELECT *
FROM your_table
WHERE your_column LIKE N'%[^ -~]%' collate Latin1_General_BIN
like image 169
Martin Smith Avatar answered Dec 04 '22 09:12

Martin Smith