zoukankan      html  css  js  c++  java
  • sql插入临时表数据的方法

    方法有两种,主要看需求。

    方法1:定义好临时表的字段和类型、插入对应的值

    create table #Tmp --创建临时表#Tmp
    (
        City   varchar(50),  --
        Country  varchar(50),   --
    );
    
    insert #Tmp
    select '北京','中国' union
    select '东京','日本' union
    select '纽约','美国' 
    
    select * from #Tmp;

    方法2:直接将查询出来的表数据插入临时表中

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

     欢迎顶....

  • 相关阅读:
    js---选择排序
    js----冒泡排序
    js---快速排序
    js---去重方法(二)
    js---去重方法(一)
    js--进度条
    随机生成6位数验证码
    倒计时
    别踩白块
    贪吃蛇小游戏
  • 原文地址:https://www.cnblogs.com/hmYao/p/6428256.html
Copyright © 2011-2022 走看看