Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 List Out Parent and Child tables

Author  Topic 

learntsql

524 Posts

Posted - 2009-12-22 : 04:06:14
Hi..
How to List out all Parent and Child tables of the database.
The problem is some of the tables are mapped with foriegn key some are not. then how to find the parent and child tables.

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2009-12-22 : 04:41:03
well if you haven't set up an implicit relationship then you are out of luck.

Do you have any kind of column / table naming convention?

For instance if your tables are like

employee

and columns that link to this logically have an [employeeId] column.

then you could probably write something using the view information_schema.columns


Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

learntsql

524 Posts

Posted - 2009-12-22 : 04:53:47
Thank you Charlie.
I will look in that way.
If foreign key is defined how to find out the related tables
as
ParentTable-->ChildTables
Go to Top of Page
   

- Advertisement -