Results 1 to 3 of 3

Thread: Word count

  1. #1
    Join Date
    Aug 2007
    Posts
    4

    Word count

    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't know 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 and not count them from the column.

  2. #2
    Join Date
    Dec 2004
    Posts
    502
    I don't understand the problem. Are you asking how to use your SQL statement for a column in a table? Like this?

    SELECT LEN(YourColumn) - LEN(REPLACE(YourColumn, ' ', '')) + 1
    AS Results
    FROM YourTable

  3. #3
    Join Date
    Aug 2007
    Posts
    4
    Hi,

    Sorry i was having a brain fart at the time. managed to get it all sorted.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •