Skip to content

Instantly share code, notes, and snippets.

@dgershman
Last active January 3, 2016 05:09
Show Gist options
  • Select an option

  • Save dgershman/8413521 to your computer and use it in GitHub Desktop.

Select an option

Save dgershman/8413521 to your computer and use it in GitHub Desktop.
DECLARE @SEARCHSTRING VARCHAR(255), @notcontain Varchar(255)
SELECT @SEARCHSTRING = 'phone_numbers', @notcontain = ''
SELECT DISTINCT OBJECT_SCHEMA_NAME(sysobjects.id) + '.' + sysobjects.name AS [Object Name] ,
case when sysobjects.xtype = 'P' then 'Stored Proc'
when sysobjects.xtype = 'TF' then 'Function'
when sysobjects.xtype = 'TR' then 'Trigger'
when sysobjects.xtype = 'V' then 'View'
end as [Object Type]
FROM sysobjects,syscomments
WHERE sysobjects.id = syscomments.id
AND sysobjects.type in ('P','TF','TR','V')
AND sysobjects.category = 0
AND CHARINDEX(@SEARCHSTRING,syscomments.text)>0
AND ((CHARINDEX(@notcontain,syscomments.text)=0
or CHARINDEX(@notcontain,syscomments.text)<>0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment