本文介绍了理解关系黑白表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果项目包含70个表.我如何理解黑白关系
这些表

if project contains 70 tables . how i can understand relationship b/w
those tables

推荐答案

Select
object_name(rkeyid) Parent_Table,
object_name(fkeyid) Child_Table,
object_name(constid) FKey_Name,
c1.name FKey_Col,
c2.name Ref_KeyCol
From
sys.sysforeignkeys s
Inner join sys.syscolumns c1
on ( s.fkeyid = c1.id And s.fkey = c1.colid )
Inner join syscolumns c2
on ( s.rkeyid = c2.id And s.rkey = c2.colid )
Order by Parent_Table,Child_Table





我测试下面一种工作方式,只需将其粘贴到SQL Server查询窗口中即可.执行



or

I test below one working just paste it in SQL server Query window & execute

select object_name(constid) FKey_Name, object_name(fkeyid) Child_Table, c1.name FKey_Col,
object_name(rkeyid) Parent_Table, c2.name Ref_KeyCol
from sysforeignkeys s
inner join syscolumns c1
on ( s.fkeyid = c1.id
and s.fkey = c1.colid  )
inner join syscolumns c2
on ( s.rkeyid = c2.id
and s.rkey = c2.colid  )









:)






or

Google is your friend
:)




这篇关于理解关系黑白表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 06:17