Skip to content
Advertisement

Dynamic SQL search improvement

I have this SQL query that I am using for dynamic search in the database:

In the database I have e.g.:

If I provide the input Microsoft Visio

I would like it to list

How can I improve my SQL query to achieve this? I have done googling, but haven’t found what I want to do exactly.

Advertisement

Answer

Either pass through your parameter as a table-valued parameter, as a list of words.

Or split it up in SQL:

Then you can unpivot your columns to search, and join it like this:

If you only want any match from the words list, it’s much easier:

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