The query returns different results.

I have 2 queries (I believe that they should return the same number of rows :)):

1.

SELECT NAME FROM myDataBase.myTable WHERE CONTAINS(NAME, 'ABC') 

2.

 SELECT NAME FROM myDataBase.myTable WHERE NAME LIKE '%ABC%' 

But in practice, I have the following results (for example):

for request (1.)

  • first query execution (1.): 980 rows were affected
  • second query execution (1.): 996 rows were affected
  • ...
  • N query execution (1.): 1000 rows were affected

and for the request (2.)

  • first query execution (2.): 1000 lines by page

So my question is: why is this happening? What am I doing wrong?:)

PS I am new to Sql Server, and I have functions, so I understand everything that I have lack of theory, I did not find anything about this question, so I decided to ask

+4
source share
2 answers

CONTAINS is a full text predicate and searches for the word "ABC" in the full text index in accordance with the current rules for interrupting a language word.

LIKE scans the column.

So LIKE will find "XABCX", while CONTAINS will not.

+2
source

CONTAINS works outside of full-text search.

It is entirely possible that FTS indices are rearranged between runs of this query. If so, then I expect the results you see.

Thus, either do not use FTS, or change the FTS distribution schedule to something more acceptable.

+1
source

All Articles