sql 创建临时表 并且插入多条数据

方法一:


create table #Tmp --创建临时表#Tmp
(
    tar   varchar(50),  --修改后 的 目标值
    res  varchar(50),   --修改前 的 值      
);

insert #Tmp
select '爱尔兰','L7667601' union
select '澳大利亚','L67AU0671' union
select '澳门','7777771' 

select * from #Tmp;
drop table #Tmp;

方法二:

if OBJECT_ID('tempdb..#temp') is not null
drop table #temp
select * into #temp from 
(
    select 7 as 'month',25 as 'salesVolume'
    union all
    select 7 as 'month',25 as 'salesVolume'
    union all
    select 8 as 'month',25 as 'salesVolume' 
    union all
    select 8 as 'month',25 as 'salesVolume'
    union all
    select 8 as 'month',25 as 'salesVolume'
    union all
    select 9 as 'month',25 as 'salesVolume'
    union all
    select 9 as 'month',25 as 'salesVolume'
    union all
    select 9 as 'month',25 as 'salesVolume'
    union all
    select 9 as 'month',25 as 'salesVolume'
) as A


select *  from #temp
阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xu_guowei/article/details/46804785
文章标签: sql 插入 临时表
个人分类: SqlServer
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭