I have a problem with SQL Server 2008 full text search I have the following query
SELECT *
FROM cigars
WHERE CONTAINS(cigars.*, @Search )
@Search is a value that is passed in through a stored procedure. But, thats not the problem.
What is is if someone searches for say ‘Punch’ it works fine and I get all cigars that match.
Where the problem lays is if they search for ‘Punch Cigar’ I get this error.
Syntax error near ‘Cigar’ in the full-text search condition ‘Punch Cigar’.
Any idea on how I can get it to allow for it to search for that phrase?
Why are you searching by all columns in the
CIGARtable? Surely some of them do not use a string/text based data type…After looking at the CONTAINS documentation, I’d look at a function to properly escape the words for the FTS searching:
Test:
…which gives me:
Usage:
Addendum
The function is simplistic:
assumes double quotes aren’t in the parameter valueTweak as needed.