SQL一些常用的查询语句


--字段查找表

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 '%表名%'


猜你喜欢

转载自blog.csdn.net/qq389216533/article/details/52224432