关闭

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

标签: sql插入临时表
5095人阅读 评论(0) 收藏 举报
分类:

方法一:


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
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:54862次
    • 积分:1195
    • 等级:
    • 排名:千里之外
    • 原创:63篇
    • 转载:3篇
    • 译文:0篇
    • 评论:2条
    最新评论