Database Dependency Chart – How to Create and Use

database-diagramsdependenciesoracle-12csql-server-2008stored-procedures

I have several SQL Server (2008 forward) and Oracle (12c forward) legacy databases running on a server… I know for a fact that various stored procedures point to other databases, like select * from OtherDB.mySchema.Products, which makes a database dependent on OtherDB

Is there a easy way to map this "interdependencies", ideally generating a chart?

Best Answer

The answers will vary for SQL Server vs Oracle.

For SQL Server, you can view dependencies of an object two ways:

  1. You can use SQL Server Management Studio (SSMS) and right click on the object. Then click on View Dependencies:

SSMS - View Dependencies

  1. You can use the following T-SQL (from the previously linked docs) to query the sys.sql_expression_dependencies system view:
SELECT * 
FROM sys.sql_expression_dependencies  
WHERE referencing_id = OBJECT_ID(N'SchemaName.ObjectName');