`
ronon
  • 浏览: 187473 次
  • 性别: Icon_minigender_2
  • 来自: 武汉
社区版块
存档分类
最新评论

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

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics