TSQL CONTAINSTABLE and wildcard
I am running a TSQL query that uses a CONTAINSTABLE statement like this
CONTAINSTABLE(<Table A>, <TargetColumn>, '01100011')
which gives me correct results. However, if I use
CONTAINSTABLE(<Table A>, <TargetColumn>, '0110001*')
the result is 0 instead. Can someone explain to me why? Wildcards AFAIK are supported as follows.
This is on MSSQL 2008R2 server
Thank you in advance: -)
source to share
According to Jeroen's comment , you need to surround your search query with double quotes (within single quotes).
The documentation gives an example CONTAINS (Description, '"top*"' )
and then says
If the text and asterisk are not delimited by double quotes, as in
CONTAINS (DESCRIPTION, 'top')
, full-text search does not consider the pattern as an asterisk.
In your case, it CONTAINSTABLE(<Table A>, <TargetColumn>, '"0110001*"')
should work as you expected.
source to share