KARPACH

WEB DEVELOPER BLOG

How to list a SQL Server table dependencies using T-SQL?

You can always use SQL Server Management Studio, just right-click on a table in object explorer and select View Dependencies.

View Dependencies

However, this way doesn’t give you the ability to copy dependencies to the clipboard or any other way to export the dependencies list. Luckily you can find the same data using SysObjects and SysDepends tables. Here is a quick T-SQL snippet that you might want to use for this purpose.

SELECT DISTINCT dobj.name,dobj.type
FROM SysObjects obj INNER JOIN 
SysDepends d ON obj.id = d.depid INNER JOIN 
SysObjects dobj ON d.id = dobj.id
WHERE obj.name = 'WorkOrder' ORDER BY dobj.type,dobj.name
Posted on February 19, 2012 by

Comments

Posted on 7/10/2012 04:53:57 AM by Neelam

Nice blog.

Posted on 8/28/2013 11:01:53 PM by Sameer

Or get SQL Negotiator Pro from www.aphilen.com

Graphically draws dependencies for tables and stored procedures etc

Posted on 9/27/2013 08:55:55 PM by taylor

great post, thanks for the tool recommendation Neelam

worked a treat

Posted on 11/4/2013 01:24:00 AM by Gavin

Great app Neelam. Thanx for rec :-)