Dave
Dave

Reputation: 81

TSQL CONTAINSTABLE and wildcard

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 :-)

Upvotes: 3

Views: 800

Answers (1)

Tim
Tim

Reputation: 5849

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.

Upvotes: 0

Related Questions