sql server 2005语句把一张表数据覆盖到另一张表
表1与表2结构一样,数据条数一样,数据字段值不一样,怎么把表1里的数据字段值覆盖到表2里。  表1                         表2---------------              ----------------------a   b   c                     a    b    c1   1   1                     1    2    32   2    2                     2    2   23   3    3                     3    3   2

解决方案 »

  1.   

    truncate table t2
    go
    insert t2 select * from t1
      

  2.   

    delete from 表2
    insert into 表2
    select * from 表1
      

  3.   

    update 表1 set b=(select b from 表2 where 表1.a=表2.a),c=(select c from 表2 where 表1.a=表2.a)
      

  4.   

    truncate table tb2
    insert into tb2 select * from tb1
      

  5.   

    truncate table tb2
    go
    insert into tb2 select * from tb1
      

  6.   

    3楼的  请问如果 set 全部字段  怎么写,不可能一个一个写吧
      

  7.   


    请问如果 set 字段为几十个 怎么写,不可能一个一个写吧
    有没有简单的方法 如表1点
      

  8.   


    是的,问如果 set 字段为几十个 怎么写,不可能一个一个写吧
    有没有简单的方法 如表1点
      

  9.   


    这个朋友回复的差不多,可是如果字段多的话 是不是要 set b=(select b from 表2 where 表1.a=表2.a),c=(select c from 表2 where 表1.a=表2.a  d = (),e=(),f=()等等的)
    有没有简单点的 如表名点 所有列的