Joined: 25 Nov 2008
|Posted: Wed Sep 25, 2013 6:59 pm Post subject: How To Covert T-SQL Logic to Regular Expressions Logic
|How To Filter the LRQ (Long Running Query) ALert using Regular Expressions
I don't know if its the way I'm asking this or if its just that the search critieria is too simple for Regular Expressions to work with but no RegEx forum I've searched is correctly answering my question. Perhaps its because some of the text such as the parenthesis are an issue because they are escape characters in the RegEx world?
I want to add a Regular Expression to the LRQ Alert (The long running query alert) that will filter out any LRQ's that contain the text below:
"WAITFOR (Receive convert(xml,message_body) from Queue"
The quotes are only for emphasis here and are not part of the text I'm trying to filter on. This text may be at the start of the SQL command/process and or it may have 0 to many characters after it and so the RegEx must filter out any querys that contain this text.
If I were to write a T-SQL query that would do this it would look like this:
DECLARE @LRQAlert VARCHAR(256)
SET @LRQALert = 'WAITFOR (Receive convert(xml,message_body) from Queue'
SELECT Case WHEN @LRQAlert LIKE'%WAITFOR (Receive convert(xml,message_body) from Queue%'
ELSE 'NO MATCH'
The above would return the value 'MATCH'.
If @LRQALewrt where set to "WAITFOR ME DOWN BY THE DOCKS" then the return would be "NO MATCH". Hopefully that will help some with this RegEx question.