June 5, 2015 at 12:59 am
Hi all,
I want find all dependent objects related to a table. I am using -
SELECT DISTINCT so.name
INTO #tmp
FROM dbo.sysobjects so
JOIN dbo.SysComments sc
ON sc.id = so.id
WHERE sc.text LIKE '%tablename%'
But, I want all those SP/functions/views that use the output of this query and so on...
Eg.
Table -> used in usp1 -> usp1 used in usp2 ...and so on
Please help.
____________________________________________________________
APJune 5, 2015 at 1:24 am
Press Alt+F1 for a selected table name in ssms editor, and see the results.
Igor Micev,My blog: www.igormicev.com
June 5, 2015 at 3:44 am
That would be table definition.
I want something like we've a table - A.
It is used in SP - usp1
I want ann the further SP's/Objects which use this usp1 as well and so on.
____________________________________________________________
APJune 5, 2015 at 3:58 am
SELECT
d.referenced_entity_name,
o.type_desc,
object_schema_name(d.referencing_id) As ReferencingSchema,
object_name(d.referencing_id) AS ReferencingObject
FROM sys.sql_expression_dependencies d
INNER JOIN sys.objects o ON d.referenced_id=o.object_id
LEFT OUTER JOIN sys.columns colz ON o.object_id = colz.object_id
AND colz.column_id = referencing_minor_id
WHERE referenced_id = OBJECT_ID(N'Users')
Igor Micev,My blog: www.igormicev.com
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply