How do I find a job that sends a specific email?
The problem with your first query is the use of unescaped brackets with the LIKE operator.

When using the LIKE operator, there are a few special characters such as brackets that require escaping if you want to look for them. Characters enclosed in brackets will tell the SQL engine to look for a match between any character listed inside (same as regular expressions).

DECLARE @string VARCHAR(100) = 'ABC'

SELECT 'match!' WHERE @string LIKE '%[CX]%' -- Sting must have a C or an X
-- Result: match!


In your case, using [AUPAIR] inside the like will only match 1 letter (either A, U, P, I or R), and not the whole word.

DECLARE @string VARCHAR(100) = 'Staging -&gt; [AUPAIR] arrivalDate trigger issue'

SELECT 'match!' WHERE @string LIKE '%Staging -&gt; [AUPAIR] arrivalDate trigger issue%'
-- Result: (none)


This will however match with the following strings (just 1 letter!):

'Staging -&gt; A arrivalDate trigger issue'
'Staging -&gt; U arrivalDate trigger issue'
'Staging -&gt; P arrivalDate trigger issue'
'Staging -&gt; I arrivalDate trigger issue'
'Staging -&gt; R arrivalDate trigger issue'


To correctly search for brackets, you can use 2 solutions:


Declare a custom ESCAPE character.

DECLARE @string VARCHAR(100) = 'Staging -&gt; [AUPAIR] arrivalDate trigger issue'

SELECT 'match!' WHERE @string LIKE '%Staging -&gt; \[AUPAIR] arrivalDate trigger issue%' ESCAPE '\'
-- Result: match!

Enclose the opening bracket with brackets.

DECLARE @string VARCHAR(100) = 'Staging -&gt; [AUPAIR] arrivalDate trigger issue'

SELECT 'match!' WHERE @string LIKE '%Staging -&gt; [[]AUPAIR] arrivalDate trigger issue%'
-- Result: match!



Please note that there is no need to escape the closing bracket since this one will only be interpreted as a LIKE special character as long as there is an opening one before it (which won't be if you escaped it).