Teradata LPAD - Left Padding

Raymond Tang Raymond Tang 0 10351 5.89 index 9/7/2020

Teradata LPAD function is used to add repeated characters at the beginning of a string to increase the string to a specified length. It can be used to add leading space or zeros to a string.

LPAD function signature

LPAD(source_string, length, fill_string)

Returns the source_stringpadded to the left with the characters in fill_stringso that the resulting string is lengthcharacters.

Pad with leading zeros

SELECT LPAD('123456789',23,'0');

Result:

00000000000000123456789

Omit fill\_string parameter

The last parameter is optional. When it is omitted, the default value is space (' ')

Example:

SELECT LPAD('123456789',23);

Result:

              123456789
sql teradata teradata-functions

Join the Discussion

View or add your thoughts below

Comments