Search code examples
sql-serverextended-propertiessysobjects

How do I map the id in sys.extended_properties to an object name


When we codegen our CRUD stored procs, we add an extended property that indicates the table they are based on. I want to be able to interrogate sys.extended_properties to get a list of procs that depend on a given table, but extended_properties holds a major_id which doesn't seem to be the same as the object_id in sys.objects or sys.sysobjects.

What is the magic join I need?


Solution

  • From the books online entry for sys.extended_properties, major_id = object_id if the class = 1, 2, or 7. If you run a manual query, what is the class of the property? My guess is that the following will work:

    select object_name([major_id]), [name], [value]
    from sys.extended_properties