I need to build a sqlserver query that if a text column has a full text index, it will be used, if not, the query will degrade to the O(N²) approach of LIKE '%word%'?
I believe the answer will be something like:
IF has_full_text_index('mycolumn') select mytable_id from mytable where contains(mycolumn, 'word') ELSE select mytable_id from mytable where mycolumn like '%word%' ENDIF
The query will be generated by a program. The query will always have just one word to match. The test to see if a column has a full text index must be quick.
While I tend to agree with Ken that you will know which of your tables belongs to a fulltext catalog, you can query
for the tables in your catalog. (via MSDN)