           ON fka.constraint_name = fk.constraint_name
          AND fka.table_name = fk.table_name
          AND fka.owner = fk.owner
+        JOIN
+          all_constraints fk2
+          ON fk2.constraint_name = fk.r_constraint_name
+          AND fk2.owner = fk.owner
         JOIN (
           SELECT
             ctp.table_name,

        ) mr
        OUTER APPLY (
          SELECT
            fk.table_name AS clean_parent
          FROM
            all_constraints fk
          JOIN

        ) mr
        OUTER APPLY (
          SELECT
            fk2.table_name AS m_table_clean_parent
          FROM
            all_constraints fk
          JOIN
