count number of characters in nvarchar column

Sam picture Sam · Jan 10, 2013 · Viewed 263.6k times · Source

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

Answer

TechDo picture TechDo · Jan 10, 2013

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

SELECT LEN(Column) FROM TABLE