Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are 𦍌 and 𧾷 are the same in SQL Server

In SSMS v17.9, connecting to an SQL Server 14.0.1000 instance, the system treats these two character the same: 𦍌 and 𧾷

I set a [Kanji] table with the [Char] NVARCHAR(2) as the primary key. After I added "𦍌", I cannot add "𧾷" since it threw a "key duplication" error.

I ran this T-SQL:

IF ( N'𦍌' = N'𧾷') PRINT 'true' ELSE PRINT 'false'

The result prints out 'true'.

like image 745
leanhluudan Avatar asked May 20 '19 11:05

leanhluudan


People also ask

What is the meaning of SQL_Latin1_General_CP1_CI_AS?

The SQL_Latin1_General_CP1_CI_AS collation is a SQL collation and the rules around sorting data for unicode and non-unicode data are different. The Latin1_General_CI_AS collation is a Windows collation and the rules around sorting unicode and non-unicode data are the same.

What are collations in SQL Server?

Collations in SQL Server provide sorting rules, case, and accent sensitivity properties for your data. Collations that are used with character data types, such as char and varchar, dictate the code page and corresponding characters that can be represented for that data type.

How can I tell if SQL Server is Express Edition?

Click Start > All Programs > Accessories > Command Prompt. At the command line, type regedit.exe. Note: By default, SQL Server Express instances are named sqlexpress, but this value may be different if another name was used when SQL Server Express was installed.


1 Answers

you have to use proper collation,

IF ( N'𦍌' COLLATE Chinese_Simplified_Stroke_Order_100_CI_AI = N'𧾷' COLLATE Chinese_Simplified_Stroke_Order_100_CI_AI) PRINT 'true' ELSE PRINT 'false'

collation can set on the fly in select statement or in DB object level

read more about collations

like image 179
Hiran Avatar answered Sep 30 '22 01:09

Hiran