content/shared/sql-reference/functions/binary-string.md
Use binary string functions to encode and decode binary string values in SQL queries.
Decode binary data from textual representation in string.
decode(expression, format)
Encode binary data into a textual representation.
encode(expression, format)
{{< expand-wrapper >}}
{{% expand "View encode query example" %}}
The following example uses the NOAA Bay Area weather sample data.
SELECT DISTINCT
location,
encode(location::string, 'hex') AS location_encoded
FROM weather
| location | location_encoded |
|---|---|
| Concord | 436f6e636f7264 |
| Hayward | 48617977617264 |
| San Francisco | 53616e204672616e636973636f |
{{% /expand %}} {{< /expand-wrapper >}}