Andy Brownsword looks for references:
When looking to migrate, consolidate or deprovision parts of a SQL solution it’s key to understand the dependencies on the objects inside.
Identifying dependencies can be challenging and I wanted to demonstrate one way to approach this. We’ll start with some objects across a couple of databases:
Read on for a pair of queries that get you on the way. Reference detection is surprisingly difficult in SQL Server, especially if you have cross-server queries. Even cross-database queries may not work the way you expect.
Another option is to use sys.dm_sql_referencing_entities
and sys.dm_sql_referenced_entities
. I wrote a blog post on the topic a long while back and included some of the caveats around these two DMFs.
[…] another option could be to use the views such as sys.sql_expression_dependencies and Kevin also commented about using the supporting functions such […]