fancy

fancy

  • NA
  • 13
  • 4.2k

Split string and loop through against a table

May 6 2013 4:47 PM
I have a string for e.g." Wills Smith & family, Practitioner " 
I want to search keywords against a 'Company' table to determine whether the string suggests a company name or its just a persons name..

I have a table in database named as  'Company' with a single column 'Name' .
The values would be 'family','Sons','Inc.' etc . So if any of the word in the string above matches this column I should return true. Like in this case 'family' matches.

I want to break above string in store procedure as array and loop through the table to find if any of the word in the string matches in table. As soon as I get one match I want to exit . So I want to query backwards in the string as mostly company names are last word like 'inc' etc .

I am looking for good approach to solve this. I am using visual studio and sqlserver (store proc)

Answers (4)