Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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 relations and is referenced in many stored procedure and views and ... .

How to I can get all Items in database that has a relation with this table?

Thanks.

question from:https://stackoverflow.com/questions/13563364/determine-which-objects-reference-a-table-in-sql-server

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
247 views
Welcome To Ask or Share your Answers For Others

1 Answer

Using sys.dm_sql_referencing_entities:

SELECT 
    referencing_schema_name, referencing_entity_name, referencing_id, 
    referencing_class_desc, is_caller_dependent
FROM 
    sys.dm_sql_referencing_entities ('mySchemaName.myTableName', 'OBJECT');
GO

where 'mySchemaName.myTableName' is your schema.table, for example 'dbo.MyTable'


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...