1

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 ?

ApolloKS09
  • 23
  • 6
  • Recommend reviewing my answer on this post as it's a very similar problem: https://stackoverflow.com/questions/71265906/full-text-search-sql-server-with-parameter/71272497#71272497 – Stephan Mar 08 '22 at 20:11

2 Answers2

0

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)

ApolloKS09
  • 23
  • 6
0

You simply can use string concatenation in select statement:

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