Word count

  • Thank goodness problem solved
     
     
     
  • What was the question???? And, if you solved it, what was the answer???

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • The magic of post editing...

     


    N 56°04'39.16"
    E 12°55'05.25"

  • And the wonder of Google cache!

    Hi,

    I was hoping somone could help. I need to count the number of words in a specfic column in a table if i didn'rtknow what the words said.

    I can count the number of words using

    DECLARE @String VARCHAR(4000)

    SET @String = ' words to be counted'

    SELECT LEN(@String) - LEN(REPLACE(@String, ' ', '')) + 1

    AS Results

    but this requires me to know what the words are.

     
    Use the same technique!
     
    SELECT Col1, LEN(Col1) - LEN(REPLACE(Col1, ' ', '')) + 1
    FROM Table1
     

    N 56°04'39.16"
    E 12°55'05.25"

  • Wonder why Seric thought that technique required knowing what the words are?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply