两个结构完全相同的表a和b,主键为index,使用SQL语句,把a表中存在但在b表中不存在的数据插入的b表中

解决方案 »

  1.   

    insert into b
      select * from a
       where not exists(select * from b where a.index=b.index)
      

  2.   


    insert b
    select a.* from a left join b on a.index = b.index where b.index is not null 不知道行不?
      

  3.   

    都对 index 是保留字,要用[index]
      

  4.   


    insert b
    select * from a
    except
    select * from b 
      

  5.   


    SQL codeinsert into b
      select * from a
       where not exists(select * from b where a.index=b.index)
    [/Quote]
      

  6.   

     
    insert into b
    from a
    where index not in (select index from b) 
      

  7.   

    insert into b
    select *
    from a
    where index not in (select index from b) 
      

  8.   

    insert into b select * from a where [index] not in (select * from b)
      

  9.   

    insert into a select * from b where not exists(select 1 from a where a.[index]=b.[index])
      

  10.   

     21世界裸身视频网聊真像大暴光2008-06-20 21:43
          我在一个网站上看见一个大学生在网上视频时身上光光的好多人看呀,我看见这样的情况就找到了网站的管理员反映,但是我在那网站申请会员后发表了几篇文章后有看见了这样的一幕,我真的想不怎么通,我就一个一个房间找看,只要可以进的 房间都是这样的情况,我真想问管理员一天到晚在做什么,为什么这么多的色情视频 怎么没有发现呢,是他们怕生气了人气和收入还是真的没有去观察过,在这里我希望有正义感的朋友多多的发表你们的观点,让我们的网络生活更加美好!!
     
     来源网站会员学习交流社区  http://51job.8bbs.cn
      

  11.   

     21世界裸身视频网聊真像大暴光2008-06-20 21:43
          我在一个网站上看见一个大学生在网上视频时身上光光的好多人看呀,我看见这样的情况就找到了网站的管理员反映,但是我在那网站申请会员后发表了几篇文章后有看见了这样的一幕,我真的想不怎么通,我就一个一个房间找看,只要可以进的 房间都是这样的情况,我真想问管理员一天到晚在做什么,为什么这么多的色情视频 怎么没有发现呢,是他们怕生气了人气和收入还是真的没有去观察过,在这里我希望有正义感的朋友多多的发表你们的观点,让我们的网络生活更加美好!!
     
     来源网站会员学习交流社区  http://51job.8bbs.cn
      

  12.   

    set IDENTITY_INSERT b on
    insert b(column1,column2,....)  select * from  a where index not in (select index from b)
      

  13.   

    insert into a select * from b where not exists(select 1 from a where a.[index]=b.[index])同意.
      

  14.   

    insert into b select * from a where not exists(select * from b where a.index=b.index)
      

  15.   

    insert into b select * from a where a.index not in (select b.index from b)
      

  16.   

    index应该用[index]或者"index"表示
      

  17.   

    insert into b
      select * from a
       where not exists(select * from b where a.[index]=b.[index])
      

  18.   

    insert b 
    select * from a 
    except 
    select * from b 能解释下为什么要加index 吗?
      

  19.   

    insert into b select a.* from a where not exists( select 1 from b where a.index=b.index )
      

  20.   

    LZ
    这个是对的,毋庸置疑
    结贴吧!
    insert into b
      select * from a
       where not exists(select * from b where a.[index]=b.[index])
      

  21.   

    两个结构完全相同的表a和b,主键为index,使用SQL语句,把a表中存在但在b表中不存在的数据插入的b表中insert into b 
    select * from (select * from a where a.index <>b.index )c
      

  22.   

    insert b 
    select * from a 
    except 
    select * from b 
      

  23.   


    采用左外联接方式
    insert into b select * from (select a.* from a left outer join b on a.[index]=b.[index] where b.[index] is null) as c
      

  24.   

    insert b 
    select * from a 
    except 
    select * from b 
    支持这种。
      

  25.   

    insert b select * from a
    except select * from b
      

  26.   

    insert into b select * from a where not exists(select * from b  where a.index=b.index) as c