RPAD

Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API

Pads a string on the right to a specified length.

Syntax

rpad(<string>, <length> [, fill])

Arguments

Required

  • <string>: The string to pad.
  • <length>: The desired total length.

Optional

  • fill: The padding characters. Defaults to space.

Returns

Returns a text value padded to the specified length.

Considerations

  • If the string is longer than the specified length, it is truncated.
  • The fill string is repeated as needed.

Examples

Right Pad

Pad a string on the right.

SELECT rpad('hi', 5, 'xy') AS result;

Returns 'hixyx'.

Related Documentation