I have a UDF that takes a space-delimited string and returns a table containing rows the individual strings. Something like this:
SplitTextReturnTable('Emmanuel John Ahmed', ' ')
// returns a table containing three rows having Emmanuel, John and Ahmed.
What I want to do is use each of the returned string to perform a search in a table to retrieve rows with data matching the strings, something similar to a for-each-statement that searches the table with each of the returned strings. Here is a pseudo code of what I want.
DECLARE @myArray ARRAY;
SET @myArray = ConvertToArray(SplitTextReturnTable('Emmanuel John Ahmed', ' '))
SELECT * FROM Customers WHERE Customers.Fullname LIKE + '%' + @myArray[0] + '%' or Customers.Fullname LIKE + '%' + @myArray[1] + '%' or Customers.Fullname LIKE + '%' + @myArray[2] + '%'
Any help would be appreciated. I would also like to know if there's a better way to perform database searching more effectively.
Thanks.