如何在Sql中对日语字符进行排序

时间:2021-01-01 20:23:09

How to sort the following Japanese Character in Sql Server,

如何在Sql Server中对以下日文字符进行排序,

賃貸人側連絡先 (Lessor side contact)
解約連絡先 (Termination contacts)
賃借人側連絡先 (Lessee side contact)
更新連絡先 (Update contact)

above order(1,3,2,4)

But, Actual order is ,(ie. output that i want)

但是,实际顺序是,(即我想要的输出)

賃貸人側連絡先 (Lessor side contact)
賃借人側連絡先 (Lessee side contact)
解約連絡先 (Termination contacts)
更新連絡先 (Update contact)

above order(1,2,3,4)

I tried like this,

我试过这样的,

select * from test order by Test `COLLATE Japanese_CS_AS_KS`

but order of result like (3,4,2,1)

但结果顺序如(3,4,2,1)

3 个解决方案

#1


4  

Looking at Windows Japanese collations rather then your SQL collations (SQL Server supports both), by trial and error, this works

查看Windows日语排序,而不是SQL排序规则(SQL Server支持两者),通过反复试验,这是有效的

DECLARE @t TABLE (id int, SomeString nvarchar(100));
INSERT @t VALUES
(1, N'賃貸人側連絡先'),
(3, N'解約連絡先'),
(2, N'賃借人側連絡先'),
(4, N'更新連絡先');

select * from @t order by SomeString COLLATE Japanese_Bushu_Kakusu_100_CS_AS_KS desc

Not sure why you need DESC though. Also note Japanese_XJIS_100_CS_AS_KS does not work

不知道为什么你需要DESC。另请注意,Japanese_XJIS_100_CS_AS_KS不起作用

#2


1  

The collation code has 3 particles at the end:

整理代码最后有3个粒子:

  • CS - case sensitive
  • CS - 区分大小写

  • AS - accent sensitive
  • AS - 重音敏感

  • KS - kanatype sensitive which is smth Japanese related (discussed in this questions)
  • KS - 与日本相关的kanatype敏感(在这个问题中讨论)

If you want a collation that is case insensitive- change CS to CI. So perhaps a different combination of sensitivities is required.

如果您想要一个不区分大小写的排序规则 - 将CS更改为CI。因此,可能需要不同的敏感性组合。

#3


1  

In addition to @gbn's answer

除了@ gbn的回答

  • 賃 has Radical-Stroke Count 154.6
  • 有Radical-Stroke Count 154.6

  • 解 has 148.6
  • 解有148.6

  • 更 has 73.3
  • 更有73.3

So the question should rather be, why do YOU want descending order?

所以问题应该是,为什么你想降序?

#1


4  

Looking at Windows Japanese collations rather then your SQL collations (SQL Server supports both), by trial and error, this works

查看Windows日语排序,而不是SQL排序规则(SQL Server支持两者),通过反复试验,这是有效的

DECLARE @t TABLE (id int, SomeString nvarchar(100));
INSERT @t VALUES
(1, N'賃貸人側連絡先'),
(3, N'解約連絡先'),
(2, N'賃借人側連絡先'),
(4, N'更新連絡先');

select * from @t order by SomeString COLLATE Japanese_Bushu_Kakusu_100_CS_AS_KS desc

Not sure why you need DESC though. Also note Japanese_XJIS_100_CS_AS_KS does not work

不知道为什么你需要DESC。另请注意,Japanese_XJIS_100_CS_AS_KS不起作用

#2


1  

The collation code has 3 particles at the end:

整理代码最后有3个粒子:

  • CS - case sensitive
  • CS - 区分大小写

  • AS - accent sensitive
  • AS - 重音敏感

  • KS - kanatype sensitive which is smth Japanese related (discussed in this questions)
  • KS - 与日本相关的kanatype敏感(在这个问题中讨论)

If you want a collation that is case insensitive- change CS to CI. So perhaps a different combination of sensitivities is required.

如果您想要一个不区分大小写的排序规则 - 将CS更改为CI。因此,可能需要不同的敏感性组合。

#3


1  

In addition to @gbn's answer

除了@ gbn的回答

  • 賃 has Radical-Stroke Count 154.6
  • 有Radical-Stroke Count 154.6

  • 解 has 148.6
  • 解有148.6

  • 更 has 73.3
  • 更有73.3

So the question should rather be, why do YOU want descending order?

所以问题应该是,为什么你想降序?