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

你可能感兴趣的:(SqlServer)