--查询某个表被哪些视图/存储过程使用(type='P':表示存储过程,type='V':表示视图) SELECT OBJECT_NAME(id) FROM syscomments WHERE id IN(SELECT object_id FROM sys.objects WHERE type='P') AND text LIKE '%TableName%'
在SQL Server 2005/2008中,查询包含某关键字的存储过程语句:code
select distinct b.name from dbo.syscomments a, dbo.sysobjects b where a.id=b.id and b.xtype='p' and a.text like '%text%' order by name