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 2000 Forums
 SQL Server Administration (2000)
 Table dependencies

Author  Topic 

erncelen
Starting Member

15 Posts

Posted - 2005-05-17 : 17:09:32
I'm new in SQL server,
and my question is...

I was asked to identify the master table and the slave tables link-related in a large database with more than 100 tables.

I mean ...in the case of 3 tables (a,b,c), table (a) has a primary key with slave table (b), and this one is linked with table c.

In this case is easy to identify the master table....---> a, and slaves b, and c, but in a large database is there a tool (also third party), or T-Sql procedure which answer to my question (any tools can resolve dependencies)?

I have tried to use the diagram provided by SQL Server Manager, but is impossible to undestand any table correlations.


Thank to everybody, any help will be appreciated....


SreenivasBora
Posting Yak Master

164 Posts

Posted - 2005-05-17 : 17:59:46
:-). Open Query analyzer and change the database name and tablename and execute the below Query.

USE <DatabaseName>
EXEC sp_depends 'TableName'




With Regards
Sreenivas Reddy B
Go to Top of Page

erncelen
Starting Member

15 Posts

Posted - 2005-05-18 : 14:55:20
Thank a lot........


May be a solution, but when I have a large database, i have to run the sp for every tables.

I need to create the dependencies, finding parent (the upper) to the lower (last child).
any other suggestion....
Thank in advance.........................


Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-05-19 : 02:26:07
You can use sp_pkeys 'TableName' or sp_fkeys 'TableName' to know the relations
Otherwise you can use this query also

select * from information_schema.KEY_COLUMN_USAGE


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

erncelen
Starting Member

15 Posts

Posted - 2005-05-19 : 12:02:36
I found the sp:

sp_Msdependencies (and helpd me by other sql expert in other forum), it looks working fine and solve partially my job.

It gives a response about any dependencies for lots of object....tables, triggers. viwes and so on, analyzing the immadiate low level, or all the tree dependencies.....for one table or globally !!!!


In T-SQL section, raclede (forum user), added this post:
to view the dependencies of particular table just right-click the table --> All Task -->Display Dependencies

Cursors are for those who doesn't know how to use SQL

raclede™

Thi solution is when you know somthing about a table, but, i repeat, i have a databse with more 300 table, I have not create it, and I was asked to find parent and child tables.......is not possible to follow this method.

I hope this useful for everybody......

Any other suggestion will be appreciated and evaluated.......


Thank
Go to Top of Page
   

- Advertisement -