Skip to content

Instantly share code, notes, and snippets.

@Jalalx
Created June 20, 2020 17:57
Show Gist options
  • Save Jalalx/11937af10e09b95842737a10ba25454c to your computer and use it in GitHub Desktop.
Save Jalalx/11937af10e09b95842737a10ba25454c to your computer and use it in GitHub Desktop.
Search in object definitions
DECLARE @SearchText varchar(100) = '%search-text%';
SELECT sm.object_id, OBJECT_NAME(sm.object_id) AS object_name, o.type, o.type_desc, sm.definition
FROM sys.sql_modules AS sm
JOIN sys.objects AS o ON sm.object_id = o.object_id
where sm.definition like @SearchText collate SQL_Latin1_General_CP1_CI_AS
ORDER BY o.type;
GO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment