BIT_LENGTH

The BIT_LENGTH function returns the length of a string expression in bits.

BIT_LENGTH(expression)

See LENGTH , CHARACTER_LENGTH , and OCTET_LENGTH for similar functions.

expression
An expression that returns a value of any built-in numeric or string data type. A numeric argument is cast to a character string before evaluating the function. For more information about converting numeric to a character string, see VARCHAR.

The result of the function is DECIMAL(31). If the argument can be null, the result can be null; if the argument is null, the result is the null value.

The result is the number of bits (bytes * 8) in the argument. The length of a string includes trailing blanks. The length of a varying-length string is the actual length in bits (bytes * 8), not the maximum length.

Example

  • Assume table T1 has a GRAPHIC(10) column called C1.
      SELECT BIT_LENGTH( C1 )
        FROM T1
    Returns the value 160.