在网上查了一些关于更改SQL SERVER2012数据库安装后的默认排序规则(Server Collation)的方法。经过实践测试,把成功的方法记录于此,方便大家查阅。具体的操作还是比较简单的:1.首先打开命令提示符,即win+r,在弹出的窗口中输入cmd即可进入命令提示符窗口;2.在命令提示符窗口中定位在你的SQL SERVER 2012安装包的根目录(注意:是SQL SERVER 2012的安装包哟)如我的安装在D盘的Download文件夹下的SQLSERVER2012SP1文件夹下,那么就进行到SQLSERVER2012SP1这个目录下3.最后运行如下命令:D:DownloadSQLServer2012SP1>Setup /QUIET /ACTION=REBUILDDATABASE /INSTANCENAME=MSSQLSERVER /SQLSYSADMINACCOUNTS=account /SAPWD=xxxxxxxx /SQLCOLLATION=Chinese_PRC_CI_AS
即可更改SQL SERVER 2012的默认排序规则(Server Collation)。第三步中的参数说明:INSTANCENAME:数据库的实例名,默认的就是:你的数据库管理账号SAPWD:sa账户的密码,可选SQLCOLLATION:需要修改成的排序规则
2. sql表中数据排列问题
selectpersonid,dressdate,name,casewhencolumn_1!=''then'column_1'endcolumn_fromZG_JUDGMENTDETAIL_Cwherecolumn_1!=''unionall
selectpersonid,dressdate,name,casewhencolumn_2!=''then'column_2'endcolumn_fromZG_JUDGMENTDETAIL_Cwherecolumn_2!=''unionall
selectpersonid,dressdate,name,casewhencolumn_3!=''then'column_3'endcolumn_fromZG_JUDGMENTDETAIL_Cwherecolumn_3!=''unionall
selectpersonid,dressdate,name,casewhencolumn_4!=''then'column_4'endcolumn_fromZG_JUDGMENTDETAIL_Cwherecolumn_4!=''unionall
selectpersonid,dressdate,name,casewhencolumn_5!=''then'column_5'endcolumn_fromZG_JUDGMENTDETAIL_Cwherecolumn_5!=''unionall
selectpersonid,dressdate,name,casewhencolumn_6!=''then'column_6'endcolumn_fromZG_JUDGMENTDETAIL_Cwherecolumn_6!=''unionall
selectpersonid,dressdate,name,casewhencolumn_7!=''then'column_7'endcolumn_fromZG_JUDGMENTDETAIL_Cwherecolumn_7!=''unionall
selectpersonid,dressdate,name,casewhencolumn_8!=''then'column_8'endcolumn_fromZG_JUDGMENTDETAIL_Cwherecolumn_8!=''unionall
selectpersonid,dressdate,name,casewhencolumn_9!=''then'column_9'endcolumn_fromZG_JUDGMENTDETAIL_Cwherecolumn_9!=''unionall
selectpersonid,dressdate,name,casewhencolumn_10!=''then'column_10'endcolumn_fromZG_JUDGMENTDETAIL_Cwherecolumn_10!=''unionall
selectpersonid,dressdate,name,casewhencolumn_11!=''then'column_11'endcolumn_fromZG_JUDGMENTDETAIL_Cwherecolumn_11!=''unionall
selectpersonid,dressdate,name,casewhencolumn_12!=''then'column_12'endcolumn_fromZG_JUDGMENTDETAIL_Cwherecolumn_12!=''unionall
selectpersonid,dressdate,name,casewhencolumn_13!=''then'column_13'endcolumn_fromZG_JUDGMENTDETAIL_Cwherecolumn_13!=''unionall
selectpersonid,dressdate,name,casewhencolumn_14!=''then'column_14'endcolumn_fromZG_JUDGMENTDETAIL_Cwherecolumn_14!=''unionall
selectpersonid,dressdate,name,casewhencolumn_15!=''then'column_15'endcolumn_fromZG_JUDGMENTDETAIL_Cwherecolumn_15!=''unionall
selectpersonid,dressdate,name,casewhencolumn_16!=''then'column_16'endcolumn_fromZG_JUDGMENTDETAIL_Cwherecolumn_16!=''unionall
selectpersonid,dressdate,name,casewhencolumn_17!=''then'column_17'endcolumn_fromZG_JUDGMENTDETAIL_Cwherecolumn_17!=''unionall
selectpersonid,dressdate,name,casewhencolumn_18!=''then'column_18'endcolumn_fromZG_JUDGMENTDETAIL_Cwherecolumn_18!=''unionall
selectpersonid,dressdate,name,casewhencolumn_19!=''then'column_19'endcolumn_fromZG_JUDGMENTDETAIL_Cwherecolumn_19!=''
3. sql数据库数字排序问题
ORDER BY cast(你的字段名 as int)
这里的原因是因为你的那个字段虽然存储了数字值,但是它是一个字符型
而字符型的 '2' 比 '11'要大 因为是从第一个字母开始比其的
4. sql 根据数量进行排序
Select Top 10 A.p_id, B.p_name, SUM(A.p_number) as SumNumber, SUM(A.p_price) as SumPrice from OrderDetails A left join Proct B ON A.p_id = B.p_id Group By A.p_id, B.p_name Order by SUM(A.p_number) DESC说明:查询结果中p_id是商品ID, p_name是商品名称,SumNumber是总数量,SumPrice是总售价记录根据总数量(SumNumber)来排序取前十条记录。另外,在联合查询中使用left join 查询时最有效率的查询方法
5. sql中表的数据的排序方式如何修改
系统默认是以聚集索引排序,主键默认是聚集索引,也可手动改成非聚集索引,你可以添加一列标识列,就是自增列,然后把聚集索引给这列,系统就会默认按添加顺序排了
6. sql数据排序
最简单的方法是增加一个置顶字段,每个公司只有唯一一个。然后先按置顶字段排序,再按时间排序。
select * from company,proct
where company.id = proct.company_id
order by proct.ding ,datetime
如果非要在一个query里解决。
select count(*),* from company,proct
where company.id = proct.company_id
group by company.id
union
select 1,* from company,proct
where company.id = proct.company_id
and proct.id not in (
select proct.id from (select count(*),* from company,proct
where company.id = proct.company_id
group by company.id))
order by datetime
但是这样的效率非常差。
7. sqlserver数据表排序问题
不晓得你这个NewId()方法是怎么写的,我自己也写过一个类似的方法,思路是这样的:
首先,获取数据表的行数。
然后在NewId()方法里int id=行数+1,这样就保证了插入的数据永远排在最后一行。
8. 怎么把sql数据库里记录排序
数据库里面的顺序本来就不受你控制,除非是使用聚集索引。
正常情况下查询数据是可以使用order
by来将输出结果排序,至于数据库内部你控制不了也没必要关心。
9. sql获取记录总数后,按总数排序
SELECT user表.id, COUNT(news.title)
FROM user表 LEFT JOIN news
ON user表.id = news.userid
GROUP BY user表.id
ORDER BY COUNT(news.title) DESC
10. sql数据库自动排序
那就不要在数据库处理的时候排序
你取出来的数据放到数组里
自己写个方法来排序