怎么把一个表的数据全部copy到另一张表(字段完全一样的)

解决方案 »

  1.   

    select * into 新表 from 旧表
      

  2.   

    用代码说话:
    create table #t (a1 int,a2 varchar(10))insert into #t 
    select 1,'abc' union all
    select 2,'adsf' union all
    select 5,'ghsdaf' union all
    select 8,'hsh' --将表一复制到表二
    select * into #t2 from #t--查看两表内容,完全一样
    select * from #t
    select * from #t2drop table #t
    drop table #t2
      

  3.   

    select * into a from a$ 报错,数据库中已存在名为 'a' 的对象
      

  4.   

    insert into a select * from a$
      

  5.   

    1.table_new 原来已经存在且字段和顺序和table_old 完全一样,
        
         insert into table_new  select * from table_old  如不一样修改对应字段即可,注意插入数据主键问题..    insert into table_new(column1,column2)
        select column1,column2 from table_old 2.数据库中不存在table_new表 很简单    select * into table_new from table_old
      

  6.   

    select * into a from a$ 报错,数据库中已存在名为 'a' 的对象
    --------------
    首先 drop table a
    因为a已经存在,不能重建.
    用insert 语法可以在已经存在表中增加记录,但是select into语法只能生成一个以前不存在的表
      

  7.   

    drop,insert语句都写了,还是已存在名为 'a' 的对象
      

  8.   


    有了就drop table a
    然后再用 select * into a from a$