TSQL CONTAINSTABLE and wildcard

761 views Asked by At

I'm running a TSQL query that uses a CONTAINSTABLE-statement like this one

CONTAINSTABLE(<Table A>, <TargetColumn>, '01100011') 

which gives me the correct results. However, If I use

CONTAINSTABLE(<Table A>, <TargetColumn>, '0110001*') 

instead, I get 0 result. Can someone please explain to my why ? AFAIK wildcards are supported like this.

This is on MSSQL Server 2008R2

Thanks in advance :-)

1

There are 1 answers

0
Tim On

As per Jeroen's comment, you need to surround your search term with double quotes (within the single quotes).

The documentation gives the example CONTAINS (Description, '"top*"' ) then says

If the text and asterisk are not delimited by double quotation marks, as in CONTAINS (DESCRIPTION, 'top'), full-text search does not consider the asterisk to be a wildcard.

In your case, CONTAINSTABLE(<Table A>, <TargetColumn>, '"0110001*"') should work as you expected.