Need listing of all relationships of tables SQL Server 2017 I have a ticket that I need to get a listing of all the relationships in one of my tables, I found that fairly easy here - I need to take it one more step - what my manager wants to see is all the tables that directly reference my main patient table, and all the ways those child tables reference all other tables.. Something like: Patient table -&gt; address table then address table is linked to the shipping table, then the shipping table is linked to xx table... so its a huge spiderweb!  has anyone had to accomplish this before?
This will get all relations discoverable through FK constraints for a database:
USE &lt;your database&gt;
GO

SELECT
  ChildSchema.name AS ChildSchema
 ,Child.name AS ChildTable  
 ,fk.name
 ,ParentSchema.name AS ParentSchema
 ,Parent.name AS ParentTable
FROM
 sys.foreign_keys FK
INNER JOIN
  sys.tables Child
    ON Child.object_id = FK.parent_object_id --Parent here means the &quot;parent&quot; of the FK, not the relation
INNER JOIN
  sys.schemas ChildSchema
    ON ChildSchema.schema_id = Child.schema_id
INNER JOIN
  sys.tables Parent
    ON Parent.object_id = FK.referenced_object_id
INNER JOIN
  sys.schemas ParentSchema
    ON ParentSchema.schema_id = Parent.schema_id
ORDER BY 
  ChildSchema.name
 ,Child.name
GO