循环相关表的依赖顺序

时间:2013-10-07 08:01:35

标签: sql-server database stored-procedures circular-dependency

我需要在数据库中找到表的依赖关系层次结构。为此,我使用了'sp_msdependency',这是一个系统存储过程。由于我的一些表是循环依赖的,我无法获得正确的层次结构或顺序。有没有办法解决这个问题,以便我得到正确的依赖顺序?

1 个答案:

答案 0 :(得分:0)

To view the objects on which a table depends

SELECT * FROM sys.sql_expression_dependencies
WHERE referenced_id = OBJECT_ID(N'Stock.BookDetails'); 


To view the objects that depend on a table

SELECT * FROM sys.sql_expression_dependencies
WHERE referencing_id = OBJECT_ID(N'Sales.POBooks');