select * into table2 FROM table1  order by id desc这样之后select * from table2 和 select *  FROM table1 的id列顺序不同。怎样order by id desc再插入临时表?

解决方案 »

  1.   

    ?
    select * from table2 和 select *  FROM table1 的id列顺序不同table2是采用的ID倒序,Table1是ID順序在ID列建一個索引create index IX_Table2_ID on Table2(ID)
      

  2.   

    怎样order by id 再插入临时表?
      

  3.   

    create table #T(.....)
    insert #T (...) select * from table1 order by IDorselect * into #T from table1 order by ID
      

  4.   

    select * into table2  from table1 order by ID好像不行哦table2和table1还是一样
      

  5.   


    你的select没有order by,在没有order by的情况下,数据按聚集索引从小到大排序,如果你的表没有聚集索引,那数据就是乱堆的,顺序是乱的,如果你的table2的id列建了聚集索引,那么顺序就对了