須要包括有幾種狀況
1、A表中有的字段B表無
2、B表有的A表無
3、兩個表字段名不一致的post
------------------------------------------------------------------------blog
若是隻對比字段名,能夠這樣it
1、A表中有的字段B表無
select name from syscolumns where id=object_id('A') and name not in(select name from syscolumns where id=object_id('B'))
2、B表有的A表無
select name from syscolumns where id=object_id('B') and name not in(select name from syscolumns where id=object_id('A'))
3、兩個表字段名不一致的
select name from syscolumns where id=object_id('A') and name not in(select name from syscolumns where id=object_id('B'))
union
select name from syscolumns where id=object_id('B') and name not in(select name from syscolumns where id=object_id('A'))io