0

I found a strange anomaly when I ran this query:

SELECT *
FROM ProductCategories 
WHERE Name_SV = 'Fibercementskivor, byggskiva, ≤ 60 vikt-% cement,' 
  

and got a result with Name_SV:

Fibercementskivor, byggskiva, = 60 vikt-% cement,

which is not equal to what I'm searching for. I then appended "AND '3≤' = '3=' " to my WHERE clause to verify that SQL Server does something weird when string comparing = and ≤ and still got a result.

What's going on here? Why is SQL Server ignoring this difference, and how can I get around this problem?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Mårten
  • 231
  • 2
  • 14
  • 4
    `Name_SV = N'Fibercementskivor, byggskiva, ≤ 60 vikt-% cement,'` Notice the unicode N – HoneyBadger Jan 11 '22 at 13:54
  • 4
    If you try a simple `SELECT '≤'`, you'll see that this indeed gets converted to `=`, courtesy of the collation mapping rules, since `≤` is not a character present in most non-Unicode collations. It's a bit unfortunate that it converts it this way instead of the usual `?` for unmappable characters, as that would make the issue much clearer. Using Unicode literals is the solution, per HoneyBadger. – Jeroen Mostert Jan 11 '22 at 14:07
  • Does this answer your question? [What is the meaning of the prefix N in T-SQL statements and when should I use it?](https://stackoverflow.com/questions/10025032/what-is-the-meaning-of-the-prefix-n-in-t-sql-statements-and-when-should-i-use-it) – Thom A Jan 11 '22 at 14:09

0 Answers0