Check if a table has self join

Answered Check if a table has self join

  • Saturday, January 26, 2013 2:09 AM
     
     

    Can somone provide a query that displays all tables that have Self Joins via RI defined?

    Thanks!


    GBM

All Replies

  • Saturday, January 26, 2013 2:32 AM
     
     Answered Has Code
    select distinct SCHEMA_NAME(schema_id) As SchemaName, OBJECT_NAME(parent_object_id) As TableName 
    from sys.foreign_keys f
    where parent_object_id = referenced_object_id

    Tom