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.
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 Viktar Karpach