Execute a CONTAINS-style Search
- Last UpdatedMay 10, 2023
- 1 minute read
CONTAINS is used when the input search term is enclosed with ‘%’ on both sides (for example, "%string%"). CONTAINS functionality primarily supports the searching for words within strings and is therefore best suited to searching text-based fields. Searching within a Tag or Document identifier is not recommended with CONTAINS. CONTAINS is based on a standard Microsoft database querying technology.
If an entire Tag ID is known, it is recommended to search without using wildcards.
During CONTAINS-style search, most of the punctuation marks, such as comma, colon, question mark, ellipsis, exclamation mark, single quotation marks, double quotes, semicolon, parentheses and apostrophe, are ignored. However, some punctuation marks, such as hyphen, underscore and forward slash, are not ignored except when used to combine words.
Examples:
-
%2"% – ignores the double quotes and matches any word that contains "2".
-
%area-piping% – ignores the hyphen and searches for phrases that have a word starting with "area", which is next to a word starting with "piping", for example, "area piping".
-
%area piping% – searches for phrases that have a word starting with "area", which is next to a word starting with "piping", for example, "area piping" .
-
%*mand*% – searches for strings within a word, so besides bringing back "mandatory", it would also return "Command".
-
%w/c% – matches any word starting with "w/c".
-
%n% or %nn% – looks for one or two numbers respectively or an occurrence of "nn" in a string.
Note: For more information on the CONTAINS function, refer to the following Microsoft site: https://docs.microsoft.com/en-us/sql/t-sql/queries/contains-transact-sql?view=sqlserver-2017