DECLARE @SearchObject VARCHAR(100)
SET @SearchObject = 'searchable_table_name' -- change 'searchable_table_name' to the table name what you want to search
SELECT sc.name [Search Object], so.name [Container Object],
CASE so.xtype
WHEN 'U' THEN 'Table'
WHEN 'P' THEN 'Stored Procedure'
WHEN 'F' THEN 'User Defined Function'
ELSE 'Other'
END
as [Container Object Type]
FROM sysobjects so
INNER JOIN syscolumns sc ON so.id = sc.id
WHERE sc.name LIKE '%' + @SearchObject + '%' AND so.xtype IN ('U','P','F') -- U : Table , P : Stored Procedure, F: User defined functions(udf)
ORDER BY [Container Object] ASC
-- Display the stored procedures that contain the table name requested.
Select text From syscomments Where text like '%from ' + @SearchObject + '%'
(Select id From sysobjects Where type='P' and name = '')
-- Display the content of a specific stored procedure (found from above)
--Exec sp_helptext 'DeleteAssetByID'