RPAD

The RPAD function returns an expression, right-padded to a specified length with the specified characters; or, when the expression to be padded is longer than the length specified after padding, only that portion of the expression that fits into the specified length.

Return Value

TEXT or NTEXT based on the data type of the expression you want to pad (text-exp).

Syntax

RPAD (text-exp , length [, pad-exp])

Parameters

text-exp

A text expression to pad.

length

The total length of the return value as it is displayed on your terminal screen. In most character sets, this is also the number of characters in the return value. However, in some multibyte character sets, the display length of a character string can differ from the number of characters in the string.

When you specify a value for length that is shorter than the length of text-exp, then this function truncates the expression to the specified length.

pad-exp

A text expression that specifies the padding characters. The default value of pad-exp is a single blank.

Examples

Example 8-92 Right-Padding a String

The following example right-pads a name with the letters "ab" until it is 12 characters long.

SHOW RPAD('Morrison',12,'ab')
Morrisonabab