I have a table with different columns. One of them is Message. I want to check multiple patterns using like in this case.
For a start position here is a simple patterns:
DECLARE @pattern VARCHAR(50) = '%|35=[A,D]|%';
For matching this pattern, I use this query:
SELECT Logid 'LogId', 'Message' Message FROM Messages WHERE LogId >= 1000 AND (m.Message like @pattern);
And it is an example of Message content:
Now I want to check a complex pattern, which is:
DECLARE @pattern VARCHAR(50) = '%|35=[A,D]|% %|34=|%';
It means that we need to have a message with %|35=[A,D]|% AND %|34=|%. I need to match with a complex pattern with n parts which there is a space between conditions. The previous example is a condition with to statement.
So, first of all, I need to create a list of conditions by splitting pattern and check all of the conditions and make a simple AND between results. I would be glad if I can do that. The last point is that the pattern is an input of a stored procedure.