The above query returns both rows.
(comments are locked)
|
|
You are having problems with collation comparisons not matching correctly. Example: The data I am trying to store is random UTF characters and not belonging to any specific language. Does the above solution still work ??
Feb 01 '11 at 02:23 AM
Jayanth
It only has to do with the collation of your database. Try out a few different collations with my example code and you will see that it will return 1 or 2 rows depending. I suggest you do a binary collation comparison to always find only one row. It will depend upon the codepage and sort order required. Try Trying my example with the collation
Feb 01 '11 at 02:45 AM
WilliamD
(comments are locked)
|
|
It looks like unicode characters 681 to 686 are threated as the same character, though they look very different... The below would logically select 0 but it does select 1 while will select 0 Even "funnier": selects this: while selects only one row: So it seems like SQL Server THINKS these are all the same character, though one can see by looking at them that they are different. Though this doesn't answer your question - WHY is this happening? - it's a confirmation that it's indeed happening also on other installations than yours... In case it helps , when inserting the data using Union instead of Union All SQl is able to identify the difference. Its only suring select that I face the issue.
Feb 01 '11 at 02:30 AM
Jayanth
(comments are locked)
|
|
your example has N in both INSERTS but your comments seem to say something different. Do you need to review the TSQL? Try this code: and your query only returns one row. try removing the N in N'¢§ķɵƆːƠØĆ˿ŷŏɟʄJ{ŖɰŤDŽʒgNjƁ˶Jčʴ!ǝ0ʭ' from your code Hi the values are Nvarchar data and distinct N'¢§ķɵƆːƠØĆ˿ŷŏɟʄJ{ŖɰŤDŽʒgNjƁ˶Jčʴ!ǝ0ʭ' AND N'¢§ķɵƆːƠØĆ˿ŷŏɟʄJ{ŖɰŤDŽʒgNjƁ˶Jčʴ!ǝ0ʪ' However when I query for N'¢§ķɵƆːƠØĆ˿ŷŏɟʄJ{ŖɰŤDŽʒgNjƁ˶Jčʴ!ǝ0ʭ' I Still get both values.
Feb 01 '11 at 02:08 AM
Jayanth
I have edited my answer, I think your first insert is wrong
Feb 01 '11 at 02:25 AM
Fatherjack ♦♦
(comments are locked)
|


I fixed the issue using the comment from William , I had used SQL collation which is langaguage specific , I needed to change it to Windows collation and set BIN2 in order for sql to understand the UTF 16 data and perform a bin level comparison on the nvarchar data regardless of UTF 8 or UTF 16.
The Below link helped understand the reasons http://msdn.microsoft.com/en-us/library/ms143350.aspx http://blogs.msdn.com/b/qingsongyao/archive/2009/04/10/sql-server-and-utf-8-encoding-1-true-or-false.aspx