SQL server SORT order does not correspond to ASCII code order

前端 未结 3 1686
野趣味
野趣味 2021-01-18 11:53

I\'m using SQL Server 2012, and I have a database with a SQL_Latin1_General_CP1_CI_AS collation:

create table testtable (c nvarchar(1) null)

i         


        
3条回答
  •  轮回少年
    2021-01-18 12:23

    If you want the sort to be in ASCII value of each character then you should mention that explicitly in Order by clause.

    select c, ASCII(c) ascvalue from #testtable order by ASCII(c)
    

    else SQL_Latin1_General_CP1_CI_AS

    tells us that the supported language is English.

    There is no BIN in the collation name that means it supports Dictionary sorting

    in Dictionary Sorting; comparison of character data is based on dictionary order ('A' and 'a' < 'B' and 'b').

    Dictionary order is default when no other ordering is defined explicitly

    CI means character data is case insensitive (that mean 'ABC' = 'abc').

    AS means character data is accent sensitive ('à' <> 'ä').

提交回复
热议问题