<field_expr> [ NOT ] LIKE <like_mask> |
Determines whether or not a given character string matches a
specified pattern. A pattern can include regular characters and
wildcard characters. During pattern matching, regular characters
must yield a case-insensitive match with the characters specified
in the character string. Wildcard characters, however, can be
matched with arbitrary fragments of the character string. Using
wildcard characters makes the LIKE operator more flexible than
using the = and != string comparison operators.
The wildcard characters that can be used in a LIKE pattern
are:
@echo off LogParser "SELECT * FROM SYSTEM WHERE Message LIKE '%ERROR%'"When this batch file is executed, the command-line shell interpreter will assume that "%ERROR%" is a reference to an environment variable, and it will try to replace this string with the value of the environment variable. In most cases, such an environment variable will not exist, and the actual command executed by the shell will look like:
LogParser "SELECT * FROM SYSTEM WHERE Message LIKE ''"Which would yeld the following error:
Error: Syntax Error: <term2>: no valid LIKE maskTo avoid this problem, use double %% wildcard characters when writing a command-line batch file, as in the following example:
@echo off LogParser "SELECT * FROM SYSTEM WHERE Message LIKE '%%ERROR%%'"
A. LIKE
The following example WHERE clause finds all the URL's in an IISW3C log file that end with ".htm":WHERE cs-uri-stem LIKE '%.htm'B. NOT LIKE
The following example WHERE clause finds all the Event Log messages that do not contain "error":WHERE Message NOT LIKE '%error%'
© 2004 Microsoft Corporation. All rights reserved.