If you wish to Select all the Views and SP's which depends on a table then we can find it from the sys.sysdepends table. It contains all the depedencies of all the tables.
Let's say you have a table 'MstEmployee' and you wish to find all the Views and SP's in which this table is referred, then write below query :
SELECT DISTINCT OBJECT_NAME(DP.ID) ObjNameFROM sys.sysdepends DPINNER JOIN sys.sysobjects OBON DP.DepID = OB.IDWHERE OB.NAME = 'MstEmployee'
---- Output --------ObjNameUSP_NewEmployeesUSP_Employee_InsertUSP_GetEmployeeDetailsUSP_CheckEmployeeExistanceVW_CorporateEmployees
Reference: Govind Badkur(http://govindbadkur.blogspot.com)
No comments:
Post a Comment