SQLTeam.com | Weblogs | Forums

Full text index error with multiple words


#1

DECLARE @Name VARCHAR(50)='John'

SELECT * FROM TableA a
WHERE CONTAINS ( a.Name, @Name );

DECLARE @Name VARCHAR(50)='John is a'

SELECT * FROM TableA a
WHERE CONTAINS ( a.Name, @Name );

Msg 7630, Level 15, State 3, Line 10
Syntax error near 'is' in the full-text search condition 'John is a'.

DECLARE @Name VARCHAR(50)='"John is a"'

SELECT * FROM TableA a
WHERE CONTAINS ( a.Name, @Name );

If I use multiple word in the parameter with single quote ,it gives me an error.I have to use double quote.Is there any way how to pass this double quotes in the parameter as user will be passing the multiple words in the application.So when user enters the multiple words like 'John is a' it takes as a '"John is a"' so there wont be any error.

Thanks in advance


#2

Never mind ,I solved the problem.
if @Name is not null
SET @Name = '"' + @Name + '"';