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

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

Casts the value of `expr` to BINARY. This function is a synonym for `CAST(expr AS BINARY)`. See [`cast` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/cast.md) for details.

## Syntax

```
binary(expr)
```

## Arguments

* `expr`: Any expression that can be cast to BINARY.

## Returns

A BINARY.

## Examples

```sql
> SELECT binary('Spark SQL');
 [53 70 61 72 6B 20 53 51 4C]

> SELECT binary(1984);
 [00 00 07 C0]
```

## Related functions

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