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

# `ascii` 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

Returns the ASCII code point of the first character of `str`.

## Syntax

```
ascii(str)
```

## Arguments

* `str`: A STRING.

## Returns

An INTEGER.

If `str` is empty, the result is 0.
If the first character is not an ASCII character or part of the Latin-1 Supplement range of UTF-16, the result is undefined.

## Examples

```sql
> SELECT ascii('234');
 50
> SELECT ascii('');
 0
```

## Related functions

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