maravilloso
6/12/2013 - 5:58 AM

Listar todas las FK's de la BD

Listar todas las FK's de la BD

SELECT CAST(a.tabname AS VARCHAR(15)) AS tabla,
        CAST(constrname AS VARCHAR(20)) AS FK,
        CAST(d.tabname AS VARCHAR(15)) AS referenciada,
        delrule
  FROM systables a, sysconstraints b, sysreferences c,
       systables d
 WHERE b.constrtype = 'R'
   AND a.tabid = b.tabid
   AND b.constrid = c.constrid
   AND c.ptabid = d.tabid