select id = 1
into #a
union all
select 3
union all
select 2
union all
select 5
union all
select 4select * from #adrop table #a该查询的结果一定是
1
3
2
5
4
吗? 如果数据量较大的情况下呢(超过一页)?也就是说,从没有任何约束的临时表中取数据的顺序是否一定和向临时表中存入数据的顺序一致呢?望高手指点,非常感谢!
into #a
union all
select 3
union all
select 2
union all
select 5
union all
select 4select * from #adrop table #a该查询的结果一定是
1
3
2
5
4
吗? 如果数据量较大的情况下呢(超过一页)?也就是说,从没有任何约束的临时表中取数据的顺序是否一定和向临时表中存入数据的顺序一致呢?望高手指点,非常感谢!
insert @t
select id = 1
union all
select 3
union all
select 2
union all
select 5
union all
select 4 select * from @t
/*
id
-----------
1
3
2
5
4(5 行受影响)
*/我测试表变量也一样,没有任何约束的条件下应该是按插入的顺序.
因为这是MSSQL的默认排序规则, 这个默认排序规则是在不带order by 的select中有效
具体存储的顺序, 对于into语句 来说, 就是LZ的select出来的数据是什么顺序存储就是什么顺序