• As Lowell stated, LEN() will only return the number of characters in a string (with a caveat that I'll explain in a minute) whereas DATALENGTH will return the number of bytes in a string. Generally speaking, Unicode strings will have 2 bytes per character in SQL Server.

    The caveat that I spoke of is that LEN() will NOT find/report on trailing spaces (and certain other characters) but DATALENGTH will whether of not it's a Unicode string or not.

    --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)