How to provide an escape character in the logparser LIKE
condition?
Current query:
SELECT EXTRACT_TOKEN(cs-uri-stem,1,'/') AS AppPath, Count(*) AS ReqCount
FROM <MyLogFile>
WHERE AppPath LIKE '%_%'
Example data:
+-------------+
| cs-uri-stem |
+-------------+
| 120_ABC |
| 321_XYZ |
| 11_BXY |
| ALPHA |
| BETA |
+-------------+
From the above data, I would like to filter only the rows that contains an underscore.
I tried the usual escape options in SQL like angle brackets [_]
, LIKE '%_%' ESCAPE '\' clause
, but they do not help.
From the Logparser help file:
Wildcard pattern matching characters can be used as literal characters. To use a wildcard character as a literal character, escape the wildcard character with the '\' (backslash) character.
Examples:
LIKE 'ab_d': matches the "ab_d" string (e.g. "ab_d", "AB_d")
LIKE 'a\%c%': matches all the strings that start with "a%c" (e.g. "a%cdefg", "A%c")
Your query should look like this:
SELECT EXTRACT_TOKEN(cs-uri-stem,1,'/') AS AppPath, Count(*) AS ReqCount
FROM <MyLogFile>
WHERE AppPath LIKE '%\_%'