SQLServer 临时表

1)在临时表里插入数据

select  列1,列2,列3     --列名必须是结果集中包含的列名或别名

into #临时表表名  from  表名

 

 

 

 

select  列1,列2,列3       --列名必须是结果集中包含的列名或别名

into #临时表表名  from 

(

 

     结果集

 

)  别名

 

PS.别名必须写上,不然报错

 

例1:

select Name into #temp20110608
from
(
    select top 1000 Name from TestTB
) T

 

例2:

select A into #temp20110608  --此时列名若写Name则报错
from
(
    select top 1000 Name A  from TestTB
) T

 

2)往通过Create创建的临时表内插入数据行

insert into #temp select a,b,c,d from xx

 

posted @ 2016-03-11 14:48  已注销1  阅读(1093)  评论(0编辑  收藏  举报