展会信息港展会大全

sqlserver查询某个字段在哪些表中存在
来源:互联网   发布日期:2016-02-16 10:24:40   浏览:2958次  

导读: --含有医院编号字段的所有表 select a.[name] from sysobjects a, ( select [id],count(*) b from syscolumn...

--含有医院编号字段的所有表

select a.[name] from sysobjects a,

(

select [id],count(*) b from syscolumns

where [name] ='column1'

group by [id]

)

b where a.[id]=b.[id] order by a.name asc

--同时含有医院编号和科室编号字段的所有表

select a.[name] from sysobjects a

left join

(

select [id],count(*) b from syscolumns where [name]

in('column1','column2') group by [id] having count(*)>1

) b

on a.[id]=b.[id]

where b.id is not null

赞助本站

人工智能实验室

相关热词: 开发 编程 android

AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港