Previous Topic

Next Topic

Inhoudsopgave

Book Index

DataLength

DataLength( expression )

Returns the length of an expression in bytes

Example

select DataLength( info ) from T_Part

Differences

The function DataLength behaves the same in ASE and MS SQL Server. Different results are caused by differences in the data types.

ASE implements an empty string as a string with one space. In MS SQL Server an empty string has 0 characters. As a result, DataLength gives you a result of 1 or 2 for an empty string in ASE, and a result of 0 in MS SQL Server. The result in ASE is 1 for a varchar or nvarchar empty string and 2 for a univarchar empty string.

In ASE the nchar and nvarchar data types use UTF-8 Unicode encoding, whereas unichar and univarchar use UTF-16 Unicode encoding. In MS SQL Server, nchar and nvarchar data types use UTF-16 Unicode encoding. The unichar and univarchar data types do not exist in MS SQL Server. For nchar and nvarchar, the result of the DataLength function reflects the different Unicode encodings.