好象不会呀
create table t1(id int)
insert t1 values(1)
insert t1 values(3)
insert t1 values(4)
insert t1 values(2)create index i_t1 on t1(id) select id from t1 order by id desc
id
-----------
4
3
2
1(所影响的行数为 4 行)
create table t1(id int)
insert t1 values(1)
insert t1 values(3)
insert t1 values(4)
insert t1 values(2)create index i_t1 on t1(id) select id from t1 order by id desc
id
-----------
4
3
2
1(所影响的行数为 4 行)
from table
order by cast(id as int) desc呢?
where id = 10101 or id =10100 or id =10099 只要加上有这样的or条件的话,排列顺序就变了!不明白!高人来指点下!
select id as [Caption] from DataDict
where id = 10101 or id =10100 or id =10099
order by id desc你的SQL:
select id
from DataDict
where id = 10101 or id =10100 or id =10099
order by cast(id as int) desc产生的结果,我的是按升序排列,你的是按降序排列!
我叫几个朋友在他们公司试了也是这样,是什么原因呢?星星们来帮帮忙啊!
1.你把select ID 改成select * 试一下。
2.cast(id as int)其实已经不是对ID进行排序了,可以说,这句话影响了优化的过程。
关注中。
不明白!类型变了,成了什么类型?对排序有影响吗?
对,补丁打全试试,要不重装sqlsever试试、、、
本来,我昨天写完这贴,又有一个“补贴”来的,谁知道,网断了,写好的东东没有发上来。
晕。
是这样,“1.你把select ID 改成select * 试一下。”,这里,如果你的表中不只一个ID字段,你再看一下。也就是说,你在表中再加一个无用的字段,来看一下。
呵呵,果然是BUG,打过补丁三就没事了。
试试吧,估计可以结贴了。