RPAD

functionsupportedCore SQL functions

docs.snowflake.com ↗

String & binary functions

Right-pads a string with characters from another string, or right-pads a binary value with bytes from another binary value. The argument (base) is padded to length length_expr with characters/bytes from the pad argument.

Syntax

supportedpartialnot supportednot scored

RPAD( <base>, <length_expr> [, <pad>] )

Parameters

NameRequiredDescription
baserequiredA VARCHAR or BINARY value.
length_exprrequiredAn expression that evaluates to an integer. It specifies: The number of UTF-8 characters to return if the input is VARCHAR. The number of bytes to return if the input is BINARY.
padrequiredA VARCHAR or BINARY value. The type must match the data type of the base argument. Characters (or bytes) from this argument are used to pad the base.

Returns

The data type of the returned value is the same as the data type of the base input value (VARCHAR or BINARY).

Usage notes

Collation details

- Collation applies to VARCHAR inputs. Collation doesn’t apply if the input data type of the first argument is BINARY. - No impact. Although collation is accepted syntactically, collations have no impact on processing. For example, languages with two-character and three-character letters (for example, “dzs” in Hungarian, “ch” in Czech) still count those as two or three characters (not one character) for the length argument. - The collation of the result is the same as the collation of the input. This can be useful if the returned value is passed to another function as part of nested function calls. - Currently, Snowflake allows the base and pad arguments to have different collation specifiers. However, the individual collation specifiers can’t both be retained because the returned value has only one collation specifier. Snowflake recommends that you avoid using pad strings that have a different collation from the base string.

See also

Referenced by