一周有7天,我现在是分7次select
把结果insert到中间表保存。有没有更简便的方法?

解决方案 »

  1.   

    select * from t1
    union all
    select * from t2
    union all
    select * from t3
    ...
      

  2.   

    select * into 中间表 from
    (
      select * from t1
      union all
      select * from t2
      union all
      select * from t3
      union all
      select * from t4
      union all
      select * from t5
      union all
      select * from t6
      union all
      select * from t7
    ) t
      

  3.   

    create view TotalTable
    asselect * from t1 
    union all  
    select * from t2 
    union all  
    select * from t3 
    union all  
    select * from t4 
    union all  
    select * from t5 
    union all  
    select * from t6 
    union all  
    select * from t7 GO
    这七个表的结构必须一致。以后就直接访问视图TotalTable
    就可以了
      

  4.   

    如果要把表插入到另外的一个数据表,则
    insert into 中间表
    select   *   from   t1  
    union   all    
    select   *   from   t2  
    union   all    
    select   *   from   t3  
    union   all    
    select   *   from   t4  
    union   all    
    select   *   from   t5  
    union   all    
    select   *   from   t6  
    union   all    
    select   *   from   t7  
      

  5.   

    为什么不
    insert   into   中间表 
    select       *       from       t1 where 时间in七天内?