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

> Reference material for BTRIM function.

# BTRIM

Removes the longest string containing only characters in `<trim_characters>` from both sides of the source string `<expression>`. If no `<trim_characters>` parameter is specified, the longest string containing only whitespace characters (ASCII Decimal 32) is removed from both sides of the specified source string `<expression>`.

## Syntax

```sql theme={"theme":{"light":"css-variables","dark":"css-variables"}}
BTRIM(<expression>[, <trim_characters>])
```

## Parameters

| Parameter           | Description                                                                                                                                                 | Supported input types |
| :------------------ | :---------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------- |
| `<expression>`      | An expression that returns the string to be trimmed.                                                                                                        | `TEXT`                |
| `<trim_characters>` | Optional. An expression that returns characters to trim from both sides of the `<expression>` string. If omitted, whitespace (ASCII Decimal 32) is trimmed. | `TEXT`                |

## Return Type

`TEXT`

## Examples

The following example trims the character `x` from both sides of a string:

<div className="query-window">
  ```
  SELECT BTRIM('xxThe Acceleration Cupxxx', 'x') AS result;
  ```

  | result <span>text</span> |
  | :----------------------- |
  | The Acceleration Cup     |

  <p><span>Rows: 1</span><span>Execution time: 5.48ms</span></p>
</div>

The following example trims the characters `x` and `y` from both sides of a string. Note that the ordering of characters in `<trim_characters>` is irrelevant:

<div className="query-window">
  ```
  SELECT BTRIM('xyxyThe Acceleration Cupyyxx', 'xy') AS result;
  ```

  | result <span>text</span> |
  | :----------------------- |
  | The Acceleration Cup     |

  <p><span>Rows: 1</span><span>Execution time: 4.59ms</span></p>
</div>

The following example omits the `<trim_characters>` parameter, and thus trims whitespace from both sides of a string:

<div className="query-window">
  ```
  SELECT BTRIM('   The Acceleration Cup     ') AS result;
  ```

  | result <span>text</span> |
  | :----------------------- |
  | The Acceleration Cup     |

  <p><span>Rows: 1</span><span>Execution time: 5.64ms</span></p>
</div>
