有表A中一个字段DWDM(值:12 10 45 20)
有表B中一个字段DWDM(值:12 10 45 20 23 25)
DWDM是两表的主健
怎么样把B表的数据覆盖的A表中

解决方案 »

  1.   

    insert A
    select * from B where DWDM not in (select DWDM from A)
      

  2.   

    --maybe
    update a set dwdm=b.dwdm from tablea a join tableb b on charindex(a.dwdm,b.dwdm)=1
      

  3.   

    delete A
    where DWDM not in (select DWDM from B)
      

  4.   

    TRUNCATE table A 
    insert A select * from B
    也可以..`
      

  5.   

    insert A
    select * from B where DWDM not in (select DWDM from A)
      

  6.   

    insert into A
    select * from B where DWDM not in (select DWDM from A)
      

  7.   

    create table A(DWDM int)
    insert A select 12
    union all select 10
    union all select 45
    union all select 20
    go
    create table B(DWDM int)
    insert B select 12
    union all select 10
    union all select 45
    union all select 20
    union all select 23
    union all select 25
    goinsert A 
    select DWDM from B as tmp
    where not exists(select 1 from A where DWDM=tmp.DWDM)select * from A