Determine Which Objects Reference a Table in SQL Server

后端 未结 3 1505
情深已故
情深已故 2021-01-31 03:04

I work with SQL Server 2008 and I have a database that has more than 1500 columns and about 500 stored procedures and ... .

I want to rename a table that has several re

3条回答
  •  醉话见心
    2021-01-31 03:44

    It is an another solution I found. You do not have to install any tools. Just run on query analyzer.

    Use [Database]
    Go
    
    SELECT
    referencing_schema_name = SCHEMA_NAME(o.SCHEMA_ID),
    referencing_object_name = o.name,
    referencing_object_type_desc = o.type_desc,
    referenced_schema_name,
    referenced_object_name = referenced_entity_name,
    referenced_object_type_desc = o1.type_desc,
    referenced_server_name, referenced_database_name
    --,sed.* -- Uncomment for all the columns
    FROM
    sys.sql_expression_dependencies sed
    INNER JOIN
    sys.objects o ON sed.referencing_id = o.[object_id]
    LEFT OUTER JOIN
    sys.objects o1 ON sed.referenced_id = o1.[object_id]
    WHERE
    referenced_entity_name = 'SP_Pay_GetData'
    order by referencing_object_name
    

提交回复
热议问题