I have built a T-SQL query like this:
DECLARE @search nvarchar(1000) = 'FORMSOF(INFLECTIONAL,hills) AND FORMSOF(INFLECTIONAL,print) AND FORMSOF(INFLECTIONAL,emergency)'
SELECT * FROM Tickets
WHERE ID IN (
-- unioned subqueries using CONTAINSTABLE
...
)
The GUI for this search will be an aspx page with a single textbox where the user can search.
I plan to somehow construct the search term to be like the example above (@search).
I have some concerns, though:
- Is the example search term above the best or only way to include the inflections of all words in the search?
- Should I separate the words and construct the search term in C# or T-SQL. I tend to lean toward C# for decisions/looping/construction, but I want your opinion.
- I hate building SQL dynamically because of the risk of injection. How can I guard against this?
- Should I use FREETEXTTABLE instead? Is there a way to make FREETEXT look for ALL words instead of ANY?
- In general, how else would you do this?