I'm wondering which collation should I use to get a consistent sort for a nvarchar
column containing text and emojis.
In any case the expected result is something like this (sorted by MS Excel):
First try: SQL_Latin1_General_CP1_CI_AI
SELECT Val
FROM (VALUES
(N'⭐⭐⭐'),
(N'⭐⭐⭐'),
(N''),
(N'⭐⭐'),
(N'⭐⭐'),
(N''),
(N'⭐'),
(N'❗❗'),
(N'❗❗'),
(N'❗'),
(N'❗'),
(N'❗❗❗'),
(N'❗❗❗'),
(N'bb'),
(N'ab'),
(N'aa')
) AS A (Val)
ORDER BY Val COLLATE SQL_Latin1_General_CP1_CI_AI
Result (not as excpected):
Second try (based on this answer https://stackoverflow.com/a/47551803/2336493): Latin1_General_100_CI_AS_SC
SELECT Val
FROM (VALUES
(N'⭐⭐⭐'),
(N'⭐⭐⭐'),
(N''),
(N'⭐⭐'),
(N'⭐⭐'),
(N''),
(N'⭐'),
(N'❗❗'),
(N'❗❗'),
(N'❗'),
(N'❗'),
(N'❗❗❗'),
(N'❗❗❗'),
(N'bb'),
(N'ab'),
(N'aa')
) AS A (Val)
ORDER BY Val COLLATE Latin1_General_100_CI_AS_SC;
Result (not as excpected):
Has anyone dealt with this?