您的位置:首页 > 数据库

SQL一些常用的查询语句

2016-08-16 19:56 288 查看
--字段查找表

select a.name, b.name from syscolumns a, sysobjects b
where lower(a.name) = '字段名'
and   a.id = b.id
and   b.xtype = 'u'


--知道表查存储过程
select distinct object_name(id) from syscomments where id in
(select object_id from sys.objects where type ='P') and text like'%表名%'


--根据存储过程内容查找存储过程
select b.name
from syscomments a,sysobjects b
where a.id=b.id  and b.xtype='p' and a.text like '%需要查找的内容%'


---知道表查询关联的视图的存储过程
select distinct object_name(id) from syscomments
where id in (select id from sysobjects where type  in('V','P'))
and text like '%表名%'
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  sql