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

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

Converts `expr` to hexadecimal.

## Syntax

```
hex(expr)
```

## Arguments

* `expr`: A BIGINT, BINARY, or STRING expression.

## Returns

A STRING.

The function returns the hexadecimal representation of the argument.

## Examples

```sql
> SELECT hex(17);
 11
> SELECT hex('Spark SQL');
 537061726B2053514C
```

## Related functions

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