查找数据库中含有某字段的所有表
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
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
相关文章推荐
- Sqlserver 查找数据库中含有某字段的所有表
- 查找数据库中含有某字段的所有表
- Sqlserver查找数据库中含有某字段的所有表
- 查找数据库中含有某字段的所有表 --【叶子】
- 查找数据库中含有指定数据的所有表名和字段
- [SQL] 查找数据库中含有某字段的所有表
- Sql中查找数据库中,所有包含字段的表名
- 在SQL SERVER中 用SQL语句查找数据库中含有字段的表名。
- 查找某数据库中所有的字段
- 通过游标遍历数据库中的用户表,找出所有含有NULL值字段的表名和字段名
- SQL server 2008查询数据库中含有此字段内容的所有表
- 查找数据库中所有表,及表的字段等相关信息
- 在数据库中查找含有某列的所有表
- 查找 数据库中包含某一字段的所有表的表名的mysql语句
- 查找整个数据库里面包含某一字段的所有表
- 查找出关联数据库中所有包含某个字段的表的表名
- 获取某数据库中含有某字段的所有表的脚本
- 查找数据库中包含某个字段的所有表
- 怎样将数据库中所有表中含有numeric(18,2)字段改成numeric(18,10)及将float改成numeric
- 通过游标遍历数据库中的用户表,找出所有含有NULL值字段的表名和字段名