SELECT
fk.name fkname ,
ftable.name ftablename,
fcn.name fkcol ,
rtable.name ftablename,
rcn.name rkcol
FROM
sysforeignkeys
JOIN
sysobjects fk ON sysforeignkeys.constid = fk.id
JOIN
sysobjects ftable ON sysforeignkeys.fkeyid = ftable.id
JOIN
sysobjects rtable ON sysforeignkeys.rkeyid = rtable.id
JOIN
syscolumns fcn ON sysforeignkeys.fkeyid = fcn.id AND sysforeignkeys.fkey = fcn.colid
JOIN
syscolumns rcn ON sysforeignkeys.rkeyid = rcn.id AND sysforeignkeys.rkey = rcn.colid
WHERE
ftable.id = Object_ID('PFSubAcctEQRef') --table name
呵呵,其实如果是“非联合外键”的话,查询的结果是:只要有一个外键,就是一条记录: