我的一个表中的主键是char类型的,这个类型是定死的,不能改变。
可是按照主键排序后就出问题了,成了下面序列了:
10
11
12
13
2
3
4
5
6在窗体上显示就出问题了,怎么能不按照主键排序?
或者这个问题有别的解决方法吗?
谢谢!

解决方案 »

  1.   

    没懂 你想按什么排序就用 order by 字段名就可以了  你是要怎么样啊
      

  2.   

    order by cast(主键 as int)
      

  3.   


    --因为主键默认有升序聚集索引,所以在表中是按照该字段的升序排列,可以在显示时排序,如:
    select * from 表名 order by cast(主键 as int)
      

  4.   

    有个更好的办法 加个排序字段如SordID
    select * from 表名 order by SordID
      

  5.   

    order by  convert(int,該字段)
      

  6.   

    order by cast(id as int)
      

  7.   

    order by  convert(int,該字段)
    order by cast(id as int)
    这两个都可以。