Len (string_expression) parameter: string to be evaluated
Len () function
The Len function returns the length of the value in the Text field.
SQL Len () syntax
Select Len (column_name) from table_name
We want to get the length of the value in the "City" column.
We use the following SQL statement:
Select Len (city) as lengthofaddress from persons
Returns the number of characters for the specified string expression, which does not contain trailing spaces.
bigint If the expression data type is varchar (max), nvarchar (max), or varbinary (max);
The ntext field cannot be evaluated
DATALENGTH (expression) parameter: An expression of any data type
Grammar
DATALENGTH (expression)
Parameters
Expression
An expression of any type.
return type
Int
Use ADVENTUREWORKS2008R2;
Go
Select length = datalength (name), name
From Production.Product
Order BY name;
Go
The
Returns the number of bytes used to represent any expression.
returns bigint if the expression data type is varchar (max), nvarchar (max), or varbinary (max) data type;
for varchar, varbinary, text, image, nvarchar, and ntext data types, datalength is especially useful because these data types can store variable-length data. The result of the www.111cn.net
null datalength is null.