SQL Server排序规则的应用
SQL Server排序规则在SQL数据库中都有哪些应用呢?下面就为您介绍SQL Server排序规则的应用方面的知识,如果您感兴趣的话,不妨一看。
SQL Server排序规则的应用:
sql server提供了大量的windows和sqlserver专用的排序规则,但它的应用往往被开发人员所忽略。其实它在实践中大有用处。
例1:让表name列的内容按拼音排序:
- create table #t(id int,name varchar(20))
- insert #t select 1,中
- union all select 2,国
- union all select 3,人
- union all select 4,阿
- select * from #t order by name collate chinese_prc_cs_as_ks_ws
- drop table #t
/*结果:
- id name
- ----------- --------------------
- 4 阿
- 2 国
- 3 人
- 1 中
- */
例2:让表name列的内容按姓氏笔划排序:
- create table #t(id int,name varchar(20))
- insert #t select 1,三
- union all select 2,乙
- union all select 3,二
- union all select 4,一
- union all select 5,十
- select * from #t order by name collate chinese_prc_stroke_cs_as_ks_ws
- drop table #t
/*结果:
- id name
- ----------- --------------------
- 4 一
- 2 乙
- 3 二
- 5 十
- 1 三
- */
【编辑推荐】
带您了解SQL Server标识列
SQL Server添加列及删除列
SQL SERVER TOC分页的实现方法
SQL Server系统表的应用
SQL Server UPDATE语句的用法
版权声明:
作者:后浪云
链接:https://www.idc.net/help/308505/
文章版权归作者所有,未经允许请勿转载。
THE END