需要包括有几种情况
一、A表中有的字段B表无
二、B表有的A表无
三、两个表字段名不一致的
------------------------------------------------------------------------
如果只对比字段名,可以这样
一、A表中有的字段B表无
select name from syscolumns where id=object_id('A') and name not in(select name from syscolumns where id=object_id('B'))
二、B表有的A表无
select name from syscolumns where id=object_id('B') and name not in(select name from syscolumns where id=object_id('A'))
三、两个表字段名不一致的
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'))
本文介绍了一种使用SQL来对比两个表字段的方法,包括找出A表中有而B表中没有的字段、B表中有而A表中没有的字段,以及两个表中字段名不一致的情况。这些SQL查询语句为数据库管理员提供了实用的工具。
1314

被折叠的 条评论
为什么被折叠?



