LIKE
The Historian OLE DB Provider supports the use of the LIKE
expression. Use the LIKE
expression when searching for column data similar to a specified text string. By using wildcards, you can specify the text strings that you want to search. You can use the wildcard before, after, or before and after the text that you want to search for. The *
symbol represents multiple unknown characters in a search string. The ?
wildcard represents a single unknown character.
Note: You can also use the
%
wildcard to select all tags that contain a specific string in the tag name and the _
wildcard to select all tags when you are only unsure of only one character in the tag name. You must enclose the %
or _
wildcards in single quotes (for example, '%'
or '_'
) when you use them in Historian tag names and do not use single quotes if you want them to be treated as wildcards in SQL.The first example displays how to use *
wildcards to select all tags that contain a specific string in the tag name. The second example displays how to use a ?
wildcard to select all tags when you are only unsure of one character in the tag name.
Example 1: Use LIKE With Multiple Character Replacement
SELECT * FROM ihtags WHERE tagname LIKE *.Simulation*
ORDER BY tagname
SELECT * FROM ihtags WHERE tagname LIKE %.Simulation%
Example 2: Use LIKE With Single Character Replacement
SELECT * FROM ihtags WHERE tagname LIKE MYSERVER.Simulation0000?
ORDER BY tagname
SELECT * FROM ihtags WHERE tagname LIKE MYSERVER.Simulation0000'_'
ORDER BY tagname