modifying results

Discussion in 'ASP General' started by shank, Jul 10, 2004.

  1. shank

    shank Guest

    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
     
    shank, Jul 10, 2004
    #1
    1. Advertising

  2. shank

    Jeff Cochran Guest

    On Sat, 10 Jul 2004 16:13:13 -0400, "shank" <>
    wrote:

    >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
     
    Jeff Cochran, Jul 10, 2004
    #2
    1. Advertising

  3. Hey - Don't stress out over it.

    Jeff Cochran wrote:
    > On Sat, 10 Jul 2004 16:13:13 -0400, "shank" <>
    > wrote:
    >
    >
    >>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
     
    David C. Holley, Jul 11, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Monique Y. Mudama
    Replies:
    1
    Views:
    462
    Monique Y. Mudama
    Jun 28, 2005
  2. lovecreatesbeauty
    Replies:
    8
    Views:
    1,702
    Old Wolf
    Sep 12, 2005
  3. IUnknown
    Replies:
    5
    Views:
    802
    Juan T. Llibre
    Jun 3, 2008
  4. Ken Fine
    Replies:
    3
    Views:
    553
    Steven Cheng [MSFT]
    Jul 23, 2008
  5. Paul van Delst
    Replies:
    3
    Views:
    153
    Jan Svitok
    Oct 21, 2006
Loading...

Share This Page