Using Wildcards in the CONTAINS Predicate in Enterprise Search SQL Syntax Home
Using Wildcards in the CONTAINS Predicate in Enterprise Search SQL Syntax

The CONTAINS predicate supports the use of the asterisk (*) as a wildcard character for words and phrases. You can add the asterisk only at the end of the word or phrase. The presence of the asterisk enables the prefix-matching mode. In this mode, matches are returned if the column contains the specified search word with zero or more other characters. If a phrase is provided, matches are detected if the column contains all the specified words with zero or more other characters.

Examples

The first example matches documents that have any word in the Description column beginning with "serve".

…WHERE CONTAINS(Description, 'serve*')

The second example matches documents with any phrases in the Description column that begin with "comp" and in which the next word begins with "serve". For a document to match, it must match all the terms.

… WHERE CONTAINS(Description, 'comp serve*')
Remarks

The asterisk works only for prefix-matching; it does not work for suffix-matching.

See Also

Other Resources

CONTAINS Predicate in Enterprise Search SQL Syntax
FREETEXT Predicate in Enterprise Search SQL Syntax

Community Content

Phrase search should be enclosed in double-quotation marks
Added by:artykul8
The error in documentation: WHERE CONTAINS(Description, 'comp serve*') throws an exception if you try to execute it, instead it should be enclosed in double quotes: WHERE CONTAINS(Description, ' "comp serve*" ')
© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View