-
applycation of collation
collation: 是指order by时候的排序规则,比如是否区分大小写等- The following query reports the current server collation:
下列代码指出数据库查询时目前的排序规则
- The following query reports the current server collation:
SELECT SERVERPROPERTY('Collation') AS ServerCollation
- Change collation use key word 'collate'
用关键字‘collate’来改变排序规则
ALTER DATABASE [DATABASENAME] COLLATE Chinese_PRC_CI_AS
ALTER TABLE [TABLENAME] ALTER COLUMN [COLUMNNAME] [TYPE] COLLATE Chinese_PRC_CI_AS
- only can collate be used in server/database/table/column,
but also can be used in each query
‘collate’不只可以作用于整个服务器、数据库、表或者列上,
还可以只作用于在每次的查询中
SELECT * FROM TABLE ORDER BY A COLLATE Chinese_PRC_CI_AS
-
application of TOP( )
- query top rank
TOP(N) WITH TIES 关键字是将相同的项捆绑在一起后进行排序,
然后选择排名前N位的,相同的项拥有相同的排名
- query top rank
TOP(10) WITH TIES COLUMNSNAME
--e.g. 找出排名前十的所有 000112233444456789999
- query top number
TOP(N)关键字是将所有的排序后,取前N行,相同的项排名不一样
TOP(10) COLUMNSNAME
--e.g. 找出排名前十的10个 0111223344
- SELECT A RANDOM ROW
下述代码是从表中随机挑选一行
SELECT TOP(1) *
FROM ComplianceData_test TABLESAMPLE(10 PERCENT)
ORDER BY NEWID()