Search

Friday, August 12, 2011

Query to find Dependent Objects

Use below query to find the Dependent Objects:


Select DISTINCT (OBJECT_SCHEMA_NAME(id)+'.'+ OBJECT_NAME(id)) AS [Object Name] ,(OBJECT_SCHEMA_NAME(depid)+'.'+ OBJECT_NAME(depid)) AS [Is Dependant on],OBJECTPROPERTYEX(id,'BaseType') AS [Object Type],OBJECTPROPERTYEX(depid,'BaseType') AS [Object Type of Is Dependant on] From sys.sysdepends Where OBJECTPROPERTYEX(id,'IsMSShipped')=0 -- To get only user created object

2 comments:

  1. Not working ... Giving Error Msg 195, Level 15, State 10, Line 2
    'OBJECT_SCHEMA_NAME' is not a recognized built-in function name.

    ReplyDelete
    Replies
    1. Hi Kumar,
      Yes there is one mistake.
      In above query there will be a space between

      WhereOBJECTPROPERTYEX

      It will be

      Where OBJECTPROPERTYEX

      The final query will be

      Select DISTINCT (OBJECT_SCHEMA_NAME(id)+'.'+ OBJECT_NAME(id)) AS [Object Name] ,(OBJECT_SCHEMA_NAME(depid)+'.'+ OBJECT_NAME(depid)) AS [Is Dependant on],OBJECTPROPERTYEX(id,'BaseType') AS [Object Type],OBJECTPROPERTYEX(depid,'BaseType') AS [Object Type of Is Dependant on] From sys.sysdepends Where OBJECTPROPERTYEX(id,'IsMSShipped')=0 -- To get only user created object

      Delete