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

# `luhn_check` 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 13.3 LTS and above

Returns `true` if `numStr` passes the [Luhn algorithm](https://en.wikipedia.org/wiki/Luhn_algorithm) check.

The Luhn algorithm is used for example, to validate creditcard numbers.

## Syntax

```
luhn_check(numStr)
```

## Arguments

* `numStr`: An STRING expression composed of digits `'0'` through `'9'`.

## Returns

A BOOLEAN.

If `numStr` contains any character that is not a digit the result is `false`.
If the input's last digit matches the algorithm the result is `true`

## Examples

```sql
> SELECT luhn_check('12345');
 false

> SELECT luhn_check('12344');
 true

> SELECT luhn_check('1234 4');
 false
```

## Related

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