---
title: endswith function
description: Learn the syntax of the endswith function of the SQL language in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/functions/endswith
---

# `endswith` function

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime 10.4 LTS and above

The function operates in BINARY mode if both arguments are BINARY. Returns `true` if `expr` ends with `endExpr`.

## Syntax

```
endswith(expr, endExpr)
```

## Arguments

* `expr`: A STRING or BINARY expression.
* `endExpr`: A STRING or BINARY expression which is compared to the end of `str`.

## Returns

A BOOLEAN.

If `expr` or `endExpr` is `NULL`, the result is `NULL`.

If `endExpr` is the empty string or empty binary the result is `true`.

## Examples

```sql
> SELECT endswith('SparkSQL', 'SQL');
 true

> SELECT endswith('SparkSQL', 'sql');
 false

> SELECT endswith('SparkSQL', NULL);
 NULL

> SELECT endswith(NULL, 'Spark');
 NULL

> SELECT endswith('SparkSQL', '');
 true

> SELECT endswith(x'110033', x'33');
 true
```

## Related

* [`contains` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/contains.md)
* [`startswith` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/startswith.md)
* [`substr` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/substr.md)
