Home > OS >  Full-Text Search - How to change the declared variable to a phrase
Full-Text Search - How to change the declared variable to a phrase

Time:03-08

So I am doing a FTS (Full-Text Search) on names and surnames, the issue comes in when I use spaces in either one of them.

So I have learned that using the "" inside the single quotes works. But the way I am getting these names is through a select statement and I don't know how to change that variable with the names in them to a phrase

select @fName = FirstName, @lName = LastName from Person where ....

@fName for example is John James and by doing this '"John James"' it works, but how do I do it with the above statement ?

CodePudding user response:

So I fixed the issue by using Concat as the following

    select @LastNamePhrase =  Concat('"',@LastName,'"')

    print @LastNamePhrase

    SELECT * FROM Person WHERE (CONTAINS((Surname), @LastNamePhrase))

So with this method I can do the FTS (ignore the print)

CodePudding user response:

You simply can use string concatenation in select statement:

select @fName = '"' FirstName '"', @lName = LastName from Person where ....
  • Related