Tutorial :How can I convert a user's search query into a MS SQL Full-Text Query Statement


I've search for answers for this and I can't seem to find an answer to what should be somewhat simple.

This is related to another question I asked, but it's different. What's the best way to take a user's search phrase and throw it into a CONTAINSTABLE(table, column, @phrase, topN ) phrase?

Say, for example the user inputs: Books by "Dr. Seuss"

What's the best way to turn that into something that will return results in my ContainsTAble() phrase?

I was previously parsing the search phrase and writing something like ISABOUT("Books" WEIGHT(1.0), "by" WEIGHT(0.9), "Dr. Seuss" WEIGHT(0.8)) as my @phrase but ISABOUT seems to be returning odd results... especially when one word searches are entered.

Any Ideas?


We've implemented a slightly modified version of the code found in this article on SQL Server Central. It uses the Irony Compiler Construction Kit from Codeplex.

There was a bug in the original version when starting any search query with a reserved word. For example, by searching for 'Orange', it would recognise the OR term and expect binary operands which weren't supplied. This was fixed in some code provided in the discussion forum on the article which is now up to 13 pages!

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »