This article is half-done without your Comment! *** Please share your thoughts via Comment ***
As a DBA or Database Developer, we need to find the object dependency into the current database.
Finding the Object Dependency is very useful before any alteration on object like ALTER, DROP.
Below are three reference scripts to find the object dependency.
1 2 3 4 |
SELECT OBJECT_NAME(OBJECT_ID) FROM sys.sql_modules WHERE DEFINITION LIKE '%tbl_Employee%' GO |
1 2 3 4 5 6 7 8 |
SELECT DISTINCT SO.Name ,SO.XType AS ObjectType ,SC.TEXT AS ObjectDefinition FROM syscomments AS SC INNER JOIN sysobjects AS SO ON SC.id=SO.id WHERE SC.TEXT LIKE '%tablename%' GO |
1 2 3 4 5 6 |
SELECT referencing_schema_name, referencing_entity_name, referencing_id, referencing_class_desc, is_caller_dependent FROM sys.dm_sql_referencing_entities ('SchemaName.TableName', 'Object'); GO |