Skip to content

Instantly share code, notes, and snippets.

@ftonato
Last active July 27, 2016 14:18
Show Gist options
  • Save ftonato/086f79bdd6639715d79ad76ce452cced to your computer and use it in GitHub Desktop.
Save ftonato/086f79bdd6639715d79ad76ce452cced to your computer and use it in GitHub Desktop.
SQL to search database object's definitions
-- find objects which contain 'Pilots' in defintion
DECLARE @search VARCHAR(255)
SET @search='Pilots'
SELECT DISTINCT o.NAME AS Object_Name
, o.type_desc
FROM sys.sql_modules m
INNER JOIN sys.objects o
ON m.object_id = o.object_id
WHERE m.definition LIKE '%' + @search + '%'
ORDER BY 2, 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment