Skip to content

Latest commit

 

History

History
89 lines (60 loc) · 3.68 KB

view-the-dependencies-of-a-table.md

File metadata and controls

89 lines (60 loc) · 3.68 KB
title description author ms.author ms.reviewer ms.date ms.service ms.subservice ms.topic helpviewer_keywords monikerRange
View the dependencies of a table
View the dependencies of a table with SQL Server Management Studio or Transact-SQL.
WilliamDAssafMSFT
wiassaf
randolphwest
10/28/2024
sql
table-view-index
how-to
table dependencies [SQL Server]
dependencies [SQL Server], tables
displaying dependencies
viewing dependencies
>=aps-pdw-2016 || =azuresqldb-current || =azure-sqldw-latest || >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current || =fabric

View the dependencies of a table

[!INCLUDE sqlserver2016-asdb-asdbmi-asa-pdw-fabricsqldb]

You can view a table's dependencies in [!INCLUDE ssdenoversion-md], using [!INCLUDE ssManStudioFull] or [!INCLUDE tsql].

Permissions

Requires VIEW DEFINITION permission on the database and SELECT permission on sys.sql_expression_dependencies for the database. By default, SELECT permission is granted only to members of the db_owner fixed database role. When SELECT and VIEW DEFINITION permissions are granted to another user, the grantee can view all dependencies in the database.

Use SQL Server Management Studio

View the objects on which a table depends

  1. In Object Explorer, expand Databases, expand a database, and then expand Tables.

  2. Right-click a table, and then select View Dependencies.

  3. In the Object Dependencies<object name> dialog box, select either Objects that depend on <object name>, or Objects on which<object name>depends.

  4. Select an object in the Dependencies grid. The type of object (such as "Trigger" or "Stored Procedure"), appears in the Type box.

Note

Viewing dependencies using Object Explorer > View Dependencies isn't supported in Azure Synapse Analytics. Instead, use sys.sql_expression_dependencies. Azure Synapse Analytics SQL pools support tables, views, filtered statistics, and Transact-SQL stored procedures entity types from this list. Dependency information is created and maintained for tables, views, and filtered statistics only.

Use Transact-SQL

[!INCLUDE article-uses-adventureworks]

View the table dependencies

  1. In Object Explorer, connect to an instance of [!INCLUDE ssDE].

  2. On the Standard bar, select New Query.

  3. Copy and paste the following example into the query window and select Execute.

    USE AdventureWorks2022;
    GO
    
    SELECT *
    FROM sys.sql_expression_dependencies
    WHERE referencing_id = OBJECT_ID(N'Production.vProductAndDescription');
    GO

View the objects that depend on a table

  1. In Object Explorer, connect to an instance of [!INCLUDE ssDE].

  2. On the Standard bar, select New Query.

  3. The following example returns the objects that depend on the table Production.Product. Copy and paste the following example into the query window and select Execute.

    USE AdventureWorks2022;
    GO
    
    SELECT *
    FROM sys.sql_expression_dependencies
    WHERE referenced_id = OBJECT_ID(N'Production.Product');
    GO

Related content