Skip to content
Advertisement

How to dynamically write OR clause in Contains query?

Is there a way to generate the second part of this SQL query (OR clauses) from a string split?

String split values come from :

Advertisement

Answer

You can split the string using STRING_SPLIT(), then rebuild it using STRING_AGG(), and simply pass the resulting string into CONTAINS:

Or even simpler:

In both cases, @SearchPhrase looks like this:

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement