sqlsql-server-2008datalength

count number of characters in nvarchar column


Does anyone know a good way to count characters in a text (nvarchar) column in Sql Server? The values there can be text, symbols and/or numbers.

So far I used sum(datalength(column))/2 but this only works for text. (it's a method based on datalength and this can vary from a type to another).


Solution

  • You can find the number of characters using system function LEN. i.e.

    SELECT LEN(Column) FROM TABLE