I try to implement a search-mechanism with "CONTAINS()" on a SQL Server 2014.
I've read here https://technet.microsoft.com/en-us/library/ms142538%28v=sql.105%29.aspx and in the book "Pro Full-Text Search in SQL Server 2008" that I need to use double quotes to search an exact phrase.
But e.q. if I use this CONTAINS(*, '"test"')
I receive results containing words like "numerictest" also. If I try CONTAINS(*, '" test "')
it is the same. I've noticed, that there are less results as if I would search with CONTAINS(*, '*test*')
for a prefix, sufix search, so there is definitely a delta between the searches.
I didn't expect the "numerictest" in the first statement. Is there an explanation for this behaviour?
CONTAINS(*, ' "test" ')
– CaespitoseCONTAINS(*, ' "test" ')
results the same as the first two. I would use LIKE for the exact search but it takes to long. The only solution at the moment is two search withCONTAINS(*, ' "test" ')
and than filter the results in code again... Not very beautiful... – AdapterLIKE
(which is slower due to pattern matching). If you decide to use thecontains()
approach, wrap it inside a CTE (Common table expression), and do your query against that. – Vindictive