> ## Documentation Index
> Fetch the complete documentation index at: https://docs.e6data.com/llms.txt
> Use this file to discover all available pages before exploring further.

# RPAD

> Pads or truncates a string to a requested character length.

<div className="e6-meta"><span className="e6-eyebrow e6-eyebrow--quiet">Scalar function</span></div>

Returns NULL when any supplied argument is NULL.

## Syntax

### Scalar

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
rpad(value, length [, fill])
```

## Arguments

| Name | Type | Required | Description |
| - | - | - | - |
| value | STRING | Yes | The string to transform. |
| length | INTEGER | Yes | The requested length in Unicode code points. |
| fill | STRING | No | The pattern repeated to supply padding. Default: A single space. |

## Returns

* Type: STRING
* Possible values: A padded/truncated string; negative lengths act as zero and return an empty string.
* NULL behavior: Returns NULL when any supplied argument is NULL.

## Properties

| Property | Value |
| - | - |
| Deterministic | Yes |
| Supports window usage | No |
| Exact result | Yes |

## Usage notes

* An empty fill string supplies no padding; the original string is retained when it is shorter than the requested length.
* The fill pattern repeats and is truncated to the required character count.

## Examples

### Typical behavior

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT rpad('abc', 6, 'xy') AS padded, rpad('abc', 2, 'xy') AS truncated;
```

| padded | truncated |
| - | - |
| abcxyx | ab |

### Pad with spaces by default

The quotes below make the leading or trailing spaces visible.

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT rpad('a', 3) AS result;
```

| result |
| - |
| `"a  "` |

## Limitations

* Target lengths above 2147483647 raise an execution error.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.