projectionlabs.net feedSubscribe via RSS what is this?

Archive for the 'Database' Category

length of ntext in sql server

In SQL Server, if you try len(FieldName) to return the number of characters in a field and the field is a type of Text or nText, you get an error:

Argument data type text is invalid for argument 1 of len function

The answer to this is the Datalength() function which will return the length of any expression. This can be used on all data types including text, ntext, image and varbinary.

It returns the actual number of bytes in the field.