I have the following code that looks for a specific string in all stored procedures in a database:
DECLARE @StringToSearch VARCHAR(500) SET @StringToSearch = '%nolock%'
SELECT Distinct SO.Name
FROM sysobjects SO (NOLOCK)
INNER JOIN syscomments SC (NOLOCK) on SO.Id = SC.ID
AND SO.Type = 'P'
AND SC.Text LIKE @stringtosearch
ORDER BY SO.Name
I now would like to find stored procedures THAT DON'T contain the string. I already tried NOT LIKE but I still get stored procedures with the string. Any ideas?