这运行自己查找
(select * from #T1
union
select * from #T2)
这不会(添加第一行(:
select *
into #T3
from
(select * from #T1
union
select * from #T2)
它会引发语法错误。
什么是正确的语法?
这是无效的语法,在使用派生表中的结果集时需要alias
:
select * into #t3
from (select col1, col2, . . .
from #t1
union all
select col1, col2, . .
from #t2
) t; --- alias missing
你不需要子查询。 只需在第一个select
后添加into
:
select *
into #T3
from #T1
union
select *
from #T2;
请注意,除非您确实希望产生删除重复项的开销,否则应使用union all
。