modifying results

S

shank

The SQL newsgroup sent me here....
Using the following query I get my desired results. However, in the
resulting recordset, how can I show for example 10 words before and 10 words
after the keyword or phrase that was searched upon? If I get 20 resulting
records I think it would be easier for the user to decide which they want to
view. Google does this.
thanks

DECLARE @SearchString varchar(100)
SET @SearchString = ' "stress" '
SELECT KEY_TBL.RANK, Title, Body
FROM Articles INNER JOIN
FREETEXTTABLE(Articles,*, @SearchString) AS KEY_TBL
ON Articles.ID = KEY_TBL.[KEY]
ORDER BY Rank DESC
 
J

Jeff Cochran

The SQL newsgroup sent me here....
Using the following query I get my desired results. However, in the
resulting recordset, how can I show for example 10 words before and 10 words
after the keyword or phrase that was searched upon? If I get 20 resulting
records I think it would be easier for the user to decide which they want to
view. Google does this.
thanks

DECLARE @SearchString varchar(100)
SET @SearchString = ' "stress" '
SELECT KEY_TBL.RANK, Title, Body
FROM Articles INNER JOIN
FREETEXTTABLE(Articles,*, @SearchString) AS KEY_TBL
ON Articles.ID = KEY_TBL.[KEY]
ORDER BY Rank DESC

You'll need to retrieve the article body, parse it to find the word
searched for, then parse out the ten words before and after that one
to formulate the display. There are any number of utilities that
already do this if you're looking for a canned package, but there
isn't (that I've seen) a way to retrieve only that group of words.

Naturally, you'll have difficulty with the article that has the line:

"Stress can cause distress in the stressed individual and his
mistress, seamstress and any distressed person."

:)

Jeff
 
D

David C. Holley

Hey - Don't stress out over it.

Jeff said:
The SQL newsgroup sent me here....
Using the following query I get my desired results. However, in the
resulting recordset, how can I show for example 10 words before and 10 words
after the keyword or phrase that was searched upon? If I get 20 resulting
records I think it would be easier for the user to decide which they want to
view. Google does this.
thanks

DECLARE @SearchString varchar(100)
SET @SearchString = ' "stress" '
SELECT KEY_TBL.RANK, Title, Body
FROM Articles INNER JOIN
FREETEXTTABLE(Articles,*, @SearchString) AS KEY_TBL
ON Articles.ID = KEY_TBL.[KEY]
ORDER BY Rank DESC


You'll need to retrieve the article body, parse it to find the word
searched for, then parse out the ten words before and after that one
to formulate the display. There are any number of utilities that
already do this if you're looking for a canned package, but there
isn't (that I've seen) a way to retrieve only that group of words.

Naturally, you'll have difficulty with the article that has the line:

"Stress can cause distress in the stressed individual and his
mistress, seamstress and any distressed person."

:)

Jeff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top