第1个回答 2010-05-19
假设你说的字段名称相同就算存在的话
select name from syscolumns where id=(select id from sysobjects where name='表名A')
and name in (select name from syscolumns where id=(select id from sysobjects where name='表名B'))
如果有,查询显示相同字段名
如果没有,查询显示无
第2个回答 推荐于2016-02-04
你是说的字段名还是字段的具体值?
字段名:
if (NOT exists ( select * from dbo.syscolumns where name = '字段名' and id in
(select id from dbo.sysobjects where id = object_id(N'[dbo].表名') and OBJECTPROPERTY(id, N'IsUserTable') = 1))
)
字段的具体值:
一楼的就可以,但是你必须知道要比较的两列的列名才可以本回答被提问者采纳
第3个回答 2010-05-19
if exists (select *from A where 字段 in(select 字段 from B))
print("存在")
第4个回答 2010-05-19
SELECT * FROM 表A WHERE 字段A IN (SELECT 字段B FROM 表B)