SQLServer 临时表

来源:互联网 发布:windows复制粘贴失效 编辑:程序博客网 时间:2024/05/18 21:50

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

0 0
原创粉丝点击