当前位置: 代码迷 >> Sql Server >> 插入临时表,该如何解决
  详细解决方案

插入临时表,该如何解决

热度:37   发布时间:2016-04-24 18:59:40.0
插入临时表
如下面的代码

Select ID,Color from TrimPO_InputData where HeadID=1
Union all
Select ID,Color from TrimPO_InputData where HeadID=1
Union all
Select ID,Color from TrimPO_InputData where HeadID=1

请问该如何才可以插入一张临时表?
在线等,请不吝赐教!
------解决方案--------------------
select * into #tmp from 
(
Select ID,Color from TrimPO_InputData where HeadID=1
Union all
Select ID,Color from TrimPO_InputData where HeadID=1
Union all
Select ID,Color from TrimPO_InputData where HeadID=1) a

------解决方案--------------------
呵呵,总之就是,不用特意去建立临时表,可以直接select * into #临时表名称 from 表
  相关解决方案