select pk_tbl.name as PRIMARY_KEY_TABLE ,pk_col.name as PRIMARY_KEY_COLUMN ,t_obj.name as FOREIGN_KEY_TABLE ,col.name as FOREIGN_KEY_COLUMN ,c_obj.name as CONSTRAINT_NAME from sysobjects c_obj ,sysobjects t_obj ,syscolumns col ,sysreferences ref ,sysobjects pk_tbl ,syscolumns pk_col where permissions(t_obj.id) != 0 and c_obj.xtype in ('F ') and t_obj.id = c_obj.parent_obj and t_obj.id = col.id and col.colid in (ref.fkey1,ref.fkey2,ref.fkey3,ref.fkey4,ref.fkey5,ref.fkey6, ref.fkey7,ref.fkey8,ref.fkey9,ref.fkey10,ref.fkey11,ref.fkey12, ref.fkey13,ref.fkey14,ref.fkey15,ref.fkey16) and c_obj.id = ref.constid and pk_tbl.id = ref.rkeyid and pk_col.id = pk_tbl.id and pk_col.colid = ref.rkey1 order by pk_tbl.name, pk_col.name