select * into table2 FROM table1 order by id desc这样之后select * from table2 和 select * FROM table1 的id列顺序不同。怎样order by id desc再插入临时表?
select * into table2 FROM table1 order by id desc这样之后select * from table2 和 select * FROM table1 的id列顺序不同。怎样order by id desc再插入临时表?
select * from table2 和 select * FROM table1 的id列顺序不同table2是采用的ID倒序,Table1是ID順序在ID列建一個索引create index IX_Table2_ID on Table2(ID)
insert #T (...) select * from table1 order by IDorselect * into #T from table1 order by ID
你的select没有order by,在没有order by的情况下,数据按聚集索引从小到大排序,如果你的表没有聚集索引,那数据就是乱堆的,顺序是乱的,如果你的table2的id列建了聚集索引,那么顺序就对了