SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Sorting order collation Latin1_general_Cs_As


Sorting order collation Latin1_general_Cs_As

Author
Message
arco.denouden
arco.denouden
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
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 *
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?
gstarsaini
gstarsaini
SSC-Addicted
SSC-Addicted (464 reputation)SSC-Addicted (464 reputation)SSC-Addicted (464 reputation)SSC-Addicted (464 reputation)SSC-Addicted (464 reputation)SSC-Addicted (464 reputation)SSC-Addicted (464 reputation)SSC-Addicted (464 reputation)

Group: General Forum Members
Points: 464 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):

resume
résumé
Résumé
Resumes
resumes
résumés
david.annable
david.annable
Valued Member
Valued Member (61 reputation)Valued Member (61 reputation)Valued Member (61 reputation)Valued Member (61 reputation)Valued Member (61 reputation)Valued Member (61 reputation)Valued Member (61 reputation)Valued Member (61 reputation)

Group: General Forum Members
Points: 61 Visits: 290
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.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search