--查詢某個表被哪些視圖/存儲過程使用(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