SQL Server Dependencies

前端 未结 8 1581
说谎
说谎 2020-11-28 10:00

Is there an easy way to chase down table/stored procedure/function dependencies in SQL Server 2005+? I\'ve inherited a giant application with lots of tables and even more s

相关标签:
8条回答
  • 2020-11-28 10:59

    From MSDN:

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

    We can make it fancier:

    select
    I.name depending, I.xtype dependingtype,
    E.name depended, E.xtype dependedtype
    from sys.sql_expression_dependencies D
    left outer join sysobjects I on D.referencing_id = I.id
    left outer join sysobjects E on D.referenced_id = E.id
    where 1 = 1
    and ( E.name = 'mytable' or I.name = 'mytable' )  -- customize this any way you want
    order by dependedtype, depended, dependingtype, depending
    
    0 讨论(0)
  • 2020-11-28 11:00

    I don't think it's a guaranteed-complete list, but in Management Studio you can right click on a table or stored procedure and choose the View Dependencies option.

    0 讨论(0)
提交回复
热议问题