The script below will accept the object name and list all other objects that are using/referencing this object.
    --Declare a variable or alternatively you could create 
    --a stored procedure and pass this as a parameter.
    DECLARE @objectName nvarchar(4000)
    --name of your object.
   SET @ObjectName = 'MyObject'
   SELECT
        S.NAME,
        C.Text
    FROM SysObjects S
    INNER JOIN SysComments C
        ON S.ID = C.ID
    WHERE 
        C.Text LIKE '%' + @ObjectName + '%'
For example, if I run the above script in Northwind database to check where "Categories" table is being used, I get the following result.
Happy Coding!
Thank you.
 
 
No comments:
Post a Comment
As always, your comments are welcome and appreciated!