--含有医院编号字段的所有表
select a.[name] 表名from sysobjects a,
(
select [id],count(*) b from syscolumns
where [name] ='HospitalId'
group by [id]
)
b where a.[id]=b.[id]
--同时含有医院编号和科室编号字段的所有表
select a.[name] 表名from sysobjects a
left join
(
select [id],count(*) b from syscolumns where [name]
in('HospitalId','DepartmentId') group by [id] having count(*)>1
) b
on a.[id]=b.[id]
where b.id is not null
本文提供了一种SQL查询方法,用于找出包含特定字段(如医院编号和科室编号)的所有数据库表。通过使用sysobjects和syscolumns系统表,可以有效地找到符合要求的数据表。
46万+

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



