Click here to Skip to main content
15,885,051 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
if project contains 70 tables . how i can understand relationship b/w
those tables
Posted

Use below one
SQL
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


or

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

SQL
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
:)
 
Share this answer
 
v3
1. If your on about relationships at a database level, assuming there is a documentation look at that

2. If your after how to make relationships between the tables in ADO.NET then have a look at this example

edit

to look at the details of one particular table primary key / indexes etc. In SQL Server type exec sp_help tablename where tablename is the actual table you want to know more about
 
Share this answer
 
v2
In the query window select table name and press Alt+F1. There u will get relations of the particular table with other table...
 
Share this answer
 
Comments
Sandesh M Patil 1-Sep-10 11:21am    
Reason for my vote of 1
I am getting Help window...what r you trying to say please explain
Simon_Whale 1-Sep-10 12:03pm    
press alt and F1 in the query windows (sql 2005 / 2008) but it shows all the tables / stored procedures / views for that particular database your on

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900