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

WBOY
發布: 2016-06-07 15:48:16
原創
1418 人瀏覽過

-- 含有医院编号字段的所有表 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 .

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

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

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
最新問題
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!