MCITP

MCITP

Friday, September 30, 2011

Finding all objects that are dependent on table except table.


SELECT DISTINCT
CASE
WHEN so.type = 'P' THEN 'Procedure'
WHEN so.type ='TR' THEN 'Trigger'
WHEN so.type = 'FN' THEN 'Scalar Function'
WHEN so.type = 'TF' THEN 'Table Function'
WHEN so.type = 'V' THEN 'View'
WHEN so.type = 'U' THEN 'USERTABLE'
ELSE NULL
END as Object_Type,
so.name as Dependent_objects
FROM sysobjects so
INNER JOIN sysdepends sd
ON so.id = sd.id
WHERE sd.depid = OBJECT_ID('Table_Name')
GO


No comments:

Post a Comment

Followers