Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase

Sorting order collation Latin1_general_Cs_As Expand / Collapse
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: Tuesday, April 26, 2016 6:03 AM
Points: 1, Visits: 47
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 *
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



Group: General Forum Members
Last Login: Wednesday, March 16, 2016 5:11 AM
Points: 446, Visits: 182
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):

Post #1544448
Posted Tuesday, February 25, 2014 5:34 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, August 17, 2016 5:21 AM
Points: 58, Visits: 279
If you run the following script:

,COLLATIONPROPERTY(name, 'CodePage') AS CodePage
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