Finding Dependencies Between Database Objects in SQL Server

When I need to analyze dependencies, I should find the answer for 2 questions:

1) which objects does my piece of code depends on? In this case, I get the impact from the others.
When you look at this view definition, you understand that the view depends on two tables.

2) which objects does my piece of code influence on? Now I produce the impact to others.

Microsoft SQL Server has some capabilities to analyze dependencies.

  • catalog view sys.objects
This view shows all database objects and dependencies between parent and child objects such as constraints and triggers. Additional info can be found in MSDN
There are 20 views that can obtain various information about database metadata from different angles. Full list is in MSDN
  • system stored procedure sp_depends

According to information in MSDN, this stored procedure will be removed in the future.

  • dynamic managements functions sys.dm_sql_referenced_entities and sys.dm_sql_referencing_entities


Leave a Reply

Your email address will not be published. Required fields are marked *