我想在临时表中插入数据

时间:2013-10-23 18:11:59

标签: sql sql-server

我想将此查询的结果集插入到存储过程中的临时表中。

select * from A
union all 
select * from B
union all 
select * from C

2 个答案:

答案 0 :(得分:3)

SELECT *
INTO #SomeTempTable
FROM (SELECT *
      FROM A
      UNION ALL 
      SELECT * 
      FROM B
      UNION ALL 
      SELECT *
      FROM C) D

答案 1 :(得分:2)

请尝试以下:

Insert Into #Temp
select * from A
union all 
select * from B
union all 
select * from C