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

# `bit_length` 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 bit length of string data or number of bits of binary data.

## Syntax

```
bit_length(expr)
```

## Arguments

* `expr`: An BINARY or STRING expression.

## Returns

An INTEGER.

## Examples

```sql
> SELECT bit_length('Spark SQL');
72
> SELECT bit_length('北京');
48
```

## Related functions

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