您的位置:首页 > 数据库

查找数据库中含有某字段的所有表

2014-11-13 18:30 176 查看
--含有医院编号字段的所有表

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: