Full text query question | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Full text query question

A full-text search like: SELECT statement
FROM Agent
WHERE CONTAINS(statement, ‘"Intellectual"’ ) Displays all records that contain the word “Intellectual”. Does anybody knows if there#%92s a way so each displayed record is not displayed entirely, for example, each record display only 10 words to the left and 10 words to the right of the found word “Intellectual”? I need this to display results for a website search, and I dont have space to display entire records, just a ‘summary’ of the record.
As you know that all rows returned by your query will contain the word your looking for you could use a SUBSTRING and CHARINDEX combination. e.g. SELECT substring(statement,
charindex(‘Intellectual’, statement) – 10,
len(‘Intellectual’) + 10)
FROM agent
WHERE CONTAINS(statement, ‘"Intellectual"’ ) Not pretty but should perform reasonable I would have thought because the main time will be taken in the full text index search which should be quick. The only problem you would have here is if the word is there more than once!
]]>