The LENGTH() function in SQL

The semantics of the LENGTH() SQL function differs according to the database engine.

The SQL LENGTH() function must be used with care: Each database server has different semantics for this function, regarding length and trailing blanks handling.
Note: The language provides a LENGTH built-in function which is part of the runtime system. Do not confuse this with the SQL LENGTH() function, used in SQL statements. The LENGTH() function of the language returns zero when the string expression is NULL.
Table 1. Database server support of LENGTH()
Database Server Type Function name Counting unit Significant trailing blanks for CHAR() columns Return value when NULL
IBM® DB2® UDB
LENGTH(expr)
Octets Yes NULL
IBM Informix® (1)
LENGTH(expr)
Octets No NULL
Microsoft™ SQL Server (2)
LEN(expr)
Characters No NULL
MySQL
LENGTH(expr)
Characters No NULL
Oracle Database Server
LENGTH(expr)
Characters Yes NULL
PostgreSQL
LENGTH(expr)
Characters Yes NULL
Sybase ASE (2)
LEN(expr)
Characters No NULL
SQLite
LENGTH(expr)
Characters Yes NULL

Search for LENGTH() usage in your SQL statements and review the code of the database-specific function.