Split string insert "And"


How can I split a string such as:

This is my Title

and insert "and" and wrap each word with "" to make a new string like this:

"This" and "is" and "my" and "Title"

I need this for Full-Text Contains search.

Any help is appreciated. A function would be awesome if anyone knows of one!
Who is Participating?
Jim HornConnect With a Mentor Microsoft SQL Server Developer, Architect, and AuthorCommented:
Copy-paste the below T-SQL into your SSMS, verify it runs, and modify to meet your needs.
Declare @str varchar(100) = 'This is my Title'
SELECT CHAR(34) + REPLACE(@Str, ' ', CHAR(34) + ' and ' + CHAR(34)) + CHAR(34)

Open in new window

gogetsomeAuthor Commented:
Thank you Jim!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.