Note that there are some explanatory texts on larger screens.

plurals
  1. POSQL Server Contains Full Text Function Not Returning Expected Results
    primarykey
    data
    text
    <p>I can't quite figure out why I am getting unexpected results from the following query/statement. I have included code to replicate the issue (which may not be an issue at all but more a misunderstanding on my part about how <code>contains</code> works).</p> <pre> create table dbo.temp (id int identity, description nvarchar(max)) insert dbo.temp values ('this is a website.') --this record will be returned in the select query insert dbo.temp values ('a website exists.') --this record will be returned in the select insert dbo.temp values ('go to mywebsite.net') --this record will NOT be returned in the select insert dbo.temp values ('go to mywebsite.net.') --this record will NOT be returned in the select create fulltext catalog temp create unique index idx_dbo_temp_1 on dbo.temp (id) create fulltext index on dbo.temp(description) key index idx_dbo_temp_1 on temp with change_tracking auto declare @search_client nvarchar(100) = 'website' select * from dbo.temp where contains ((description),@search_client) drop fulltext index on dbo.temp drop index idx_dbo_temp_1 on dbo.temp drop fulltext catalog temp drop table dbo.temp </pre> <p>The query will return records that have <code>website</code> in the description field but will not return the record which has <code>mywebsite.net</code> in the description field.</p> <p>Any thoughts?</p> <p>UPDATE: the <code>@search_client</code> variable will really be a parameter passed in via SSRS so declared the variable to simulate the parameter being passed in.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload