Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Sorting order collation Latin1_general_Cs_As Expand / Collapse
Author
Message
Posted Tuesday, January 7, 2014 2:03 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, July 16, 2014 7:53 AM
Points: 1, Visits: 45
Hi there,

I have created a temporary table with a column "name". I have used Latin1_general_Cs_As as collation. In the table I included several rows (please examine the code).

create table #Names
(
sequence int,
name varchar(160) COLLATE Latin1_general_Cs_As
)

insert #Names
select 2, 'Byee'
union all
select 1, 'Byl'
union all
select 4, 'By'
union all
select 3, 'Bÿ'
union all
select 5, 'B'


select *
from
#Names
order by
name, sequence

After I execute the code, I get the following results:

sequence	name
5 B
4 By
3 Bÿ
2 Byee
1 Byl

I do not understand that the value "Byee" is ordered after "Bÿ". I would expect that the value "Byee" is positioned directly after "By". And I would expect that "Bÿ" is the last row.

Can somebody explain the results?
Post #1528377
Posted Monday, February 24, 2014 5:04 AM


SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Thursday, July 24, 2014 5:02 AM
Points: 411, Visits: 129
Here the collate type that you have chosen is case sensitive and accent sensitive.
The sorting is performed on two levels.
1)b and B will be treated differently.As in your example there are only 'B' so primary level sorting is no issue.But here Bÿ will come before By1.
2)Now as the collation is accent sensitive y and ÿ are treated differently.

Consider this example:
The following list has been sorted on the primary level (resume comes before resumes) and on the secondary level (strings without diacritics come before strings with diacritics):

resume
résumé
Résumé
Resumes
resumes
résumés
Post #1544448
Posted Tuesday, February 25, 2014 5:34 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, July 23, 2014 8:24 AM
Points: 43, Visits: 234
If you run the following script:

SELECT
description
,COLLATIONPROPERTY(name, 'CodePage') AS CodePage
,COLLATIONPROPERTY(name, 'LCID') AS LCID
FROM fn_helpcollations()
WHERE name = N'Latin1_General_CS_AS';

(apologies to the original author, I can't remember where I got it from!)

This will give you your code page number and locale ID. This may help you find further information based on your location.
Post #1544857
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse