Sorting order collation Latin1_general_Cs_As

  • 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:

    sequencename

    5B

    4By

    3Bÿ

    2Byee

    1Byl

    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?

  • 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

  • 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.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply