QuestionHow can I find out what database dependencies there are with tables, views, and stored procedures?
You can run the following command line:
sp_depends %Database Object Name%
The database object name is the name of a table, view, stored procedure, or function.
The attached file is a SQL query that can run through a database and return all the dependencies in a table. There are four possible displays mode (just change the @DisplayChoice value) of this SQL script.
- Choice one (default) shows the object type, database object name, and tables/views that it depends on (extends four columns out from the database object name).
- Choice two shows the user's table name (a database object name) and the count of other of database objects that counts on that object.
- Choice three shows the all table/view names and what is dependent on it (views, stored procedure)
- Choice four shows the all table/view names and the count of other of database objects that counts on that table.
Note: You can use the SQL script to see the connection between the database object (tables, views, and stored procedures) to explore the database or troubleshoot possible connection in the database.