Sunday, July 13, 2014

SQL Server-find dependents objects (sps, Procs, Table & View)

Sometimes we forget Stored Procedures name that we have created for any specific action/process. At that case we can easily find out name of that procedure using below DB script.

It is also useful to find dependent objects when ever we want to drop any DB object as well find out all the objects having keyword you want to search for.

Following code will help you to find all the DB Objects i.e.Stored Procedures,Tables,Views which are related to one or more specific tables. sp_help and sp_depends does not always return accurate results.

SELECT DISTINCT so.name,so.*,sc.*
FROM syscomments sc
INNER JOIN sysobjects so ON sc.id=so.id
WHERE sc.TEXT LIKE '%sapdb.dbo%'

0 comments:

 
Powered by Code Imagine