How To Covert T-SQL Logic to Regular Expressions Logic

SQL Server performance monitoring and alerting

Moderators: eddie davis, priyasinha, Adam, chriskelly, Chris Lambrou, Chris Spencer, eddie davis, priyasinha, Adam, chriskelly, Chris Lambrou, Chris Spencer

How To Covert T-SQL Logic to Regular Expressions Logic

Postby EdCarden » Wed Sep 25, 2013 6:59 pm

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%'
THEN 'MATCH'
ELSE 'NO MATCH'
END

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.


Thanks
EdCarden
 
Posts: 90
Joined: Tue Nov 25, 2008 6:26 pm

Return to SQL Monitor 3

Who is online

Users browsing this forum: No registered users and 0 guests