Counter of characters

  • Hi everybody, I want to count all characters(numbers, letters) from my table...someone know the way of do it this.

    Thanks for your help!

  • Lisset (2/14/2011)


    Hi everybody, I want to count all characters(numbers, letters) from my table...someone know the way of do it this.

    Thanks for your help!

    What do you want to count for things like the INTEGER datatype?

    We really need a bit more information as to what you actually want to do and why. We need to know "why" so we can give you the best solution one of which may already exist in SQL Server itself.

    --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)
    Intro to Tally Tables and Functions

  • Assuming the most simplest requirement, something like the following?

    SELECT SUM(SUM(LEN(Field_A)) + SUM(LEN(Field_B)) + SUM(LEN(Field_C)))

    FROM Table_X

  • Thanks diamondgm! The solution was:

    select sum(len(ltrim(rtrim(replace(Column1,' ',''))))+len(ltrim(rtrim(replace(Column1,' ',''))))

    from table

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

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