A表字段有100个 
B 表字段有98个
如何区别其中两个是什么字段

解决方案 »

  1.   

    select name from syscolumns where id=object_id('A表')
    except
    select name from syscolumns where id=object_id('B表')
      

  2.   

    select a.name
    from syscolumns a
    left join syscolumns b
    on a.name=b.name
    and b.id=object_id('B')
    and a.id=object_id('A')
    where a.id=object_id('A')
    and b.id is null
      

  3.   

    消息 156,级别 15,状态 1,第 2 行
    在关键字 'except' 附近有语法错误。
      

  4.   

    2000?
    select name from syscolumns 
    where id=object_id('A表')
    and name not in (select name from syscolumns where id=object_id('B表'))
      

  5.   


    select * from a not exists (select 1 from b on a.主关键字=b.字段)---a表中b没有的字段
    select * from b not exists (select 1 from b on b.主关键字=a.字段)---b表中a没有的字段