Previous Topic Next topic Print topic


LENGTH

Restriction: This topic applies to Windows environments only.
ANSI DB2 SQL/DS XDB
  X   X

Finds the length of x, where x is any field value. XDB mode recognizes either LENGTH or XLENGTH, while DB2 mode only recognizes LENGTH. The format appears below:

LENGTH(x)

The character count returned depends on the compatibility setting in effect at the time the data value was inserted into the table -- not your current compatibility setting. For example, if you inserted the field value when in DB2 mode, the LENGTH function includes trailing blanks in the character count (up to the length of the column). If you inserted the field value when in XDB mode, the LENGTH function does not count trailing blanks.

For example, if the lname column values were inserted while in XDB mode, the following query produces the result shown:

SELECT lname, LENGTH(lname)
FROM employee
lname
length(lname)
Kerin 5
Wilson 6
Crisp 5
Hopkins 7
Previous Topic Next topic Print topic