select fk.name fkname
,ftable.name ftablename
,cn.name fkcol
,rtable.name ftablename
,cn1.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 cn on sysforeignkeys.fkeyid = cn.id
and sysforeignkeys.fkey = cn.colid
join syscolumns cn1 on sysforeignkeys.rkeyid = cn1.id
and sysforeignkeys.rkey = cn1.colid
where fk.name=‘FK_PolicyData_System_CompanyTree‘
原文地址:https://www.cnblogs.com/Purk/p/8548368.html
时间: 2024-10-10 17:30:14