sqlserver关联表


select object_name(ref.fkeyid) as foreigntable, col_name(ref.fkeyid, fk.fkey) as foreignkey,
object_name(ref.rkeyid) as primarytable, col_name(ref.rkeyid, fk.rkey) as primarykey
from sysreferences ref
join sysobjects obj on ref.constid=obj.id
join sysforeignkeys fk on obj.id=fk.constid
where object_name(ref.rkeyid)='主表' and col_name(ref.rkeyid, fk.rkey)='主键'

posted @ 2022-02-25 14:35  丶Ronnie  阅读(163)  评论(0)    收藏  举报