Friday, July 20, 2012

Search DBO object's(table,Sp,function,etc.) dependencies in Other Databases


We can use 3 different approaches to find dependencies of  a data base object (e.g table,Sp,function , etc.).

 1. In this way , we use GUI to find an object in same database and this the limitation of this approach
that we are only find the dependencies in same database.
One of the most basic way to identify if a particular data base object has dependencies on other objects in same database.


2. If we arent able to find dependencies in same database we might have a scenario where need to check other database of same application. So if this is the case, we can use following script to find it in other db:

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

3. One the other way is to use Sp_depends sp to identify dependencies of a database object into Database.

exec sp_depends 'Sp_NeedToSearch'

name                                         type             
-------------------------------------------- ---------------- 
dbo.sp_depn1                                stored procedure
dbo.sp_depn2                                stored procedure
dbo.viewOfTb                                view

Source of Information :
 Finding-Database-Object-Dependencies
 msdn help for finding dependencies

Above links and article helps you to find dependencies in same data base if our object is to look across database or across server we have another good article on msdn site on link Check Dependencies across database or across server . I am hoping this will help you on finding solution for your specific problem.


Happy Living……..
Happy Coding……….
Happy Concepts……….


No comments:

Post a Comment