SQL Query and Unicode Issue

穿精又带淫゛_ 提交于 2019-12-11 02:37:57

问题


I have a really weird issue with Sql queries on unicode data. Here's what I've got:

  • Sql Server Express 2008 R2 AS
  • Table containing chinese characters/words/phrases (100,000 rows)

When I run the following, I get the correct row + 36 other rows returned... when it should only be the one row:

SELECT TOP 1000 [ID]
      ,[MyChineseColumn]
      ,UNICODE([MyChineseColumn])
  FROM [dbo].[MyTableName]
  WHERE [MyChineseColumn]= N'㐅'

As you'd expect, the row with is returned, but also the following: , , and a bunch of others...

Anyone have any ideas what is going on here? This has really got me confused and I am not sure how to solve this one (tried "Googling" already)...

Thanks


回答1:


Please check the column is using an appropriate Chinese collation as that will determine the semantics used in this type of comparison.




回答2:


You may want to try and use a binary collation, these characters seem to be somehow matched as identical (possibly by ignoring case and/or accents, depending on the used collation).



来源:https://stackoverflow.com/questions/4887447/sql-query-and-unicode-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!