Stairway to Exploring Database Metadata Level 4: Using the Dynamic Online Catalog to Explore Keys and Relationships

  • Comments posted to this topic are about the item Stairway to Exploring Database Metadata Level 4: Using the Dynamic Online Catalog to Explore Keys and Relationships

    Best wishes,
    Phil Factor

  • Thank you Mr. Factor!

    This article was one of the better reads I have had in recent memory.

    Regarding the FKRelationshipsFor procedure, Line 59 there is a bug whereby I think you meant to add the fk.name as a comment. 😀

    -->Bug here ), 18, 2000) + CHAR(13)+CHAR(10)+ ' – ' + fk.name AS script

    -->Replace with ), 18, 2000) + CHAR(13)+CHAR(10)+ ' -- ' + fk.name AS script

  • Yes, that seems to be a problem in the formatting. (sigh). I'll get Webmaster to change it.

    Best wishes,
    Phil Factor

  • Thanks for the article.

  • Is the following correct? I think you want a property value other than "IsPrimaryKey" based on the description and the output (in the article).

    Alternatively, you can use the system views to list all the constraints, as in the following query:

    SELECT 
    OBJECT_SCHEMA_NAME(Parent_Object_ID) + '.'
    + OBJECT_NAME(Parent_Object_ID) AS TheTable,
    Name
    FROM sys.objects
    WHERE OBJECTPROPERTYEX(object_id, 'IsPrimaryKey') = 1
    ORDER BY TheTable;

    ------------
    Buy the ticket, take the ride. -- Hunter S. Thompson

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply