A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.snowflake.com/en/sql-reference/functions/hex_decode_string below:

Website Navigation


HEX_DECODE_STRING | Snowflake Documentation

HEX_DECODE_STRING

Decodes a hex-encoded string to a string.

See also:

TRY_HEX_DECODE_STRING

Syntax
HEX_DECODE_STRING(<input>)

Copy

Arguments
input

A hex-encoded string expression. Typically the input was created by a call to HEX_ENCODE.

Returns

The returned value is a string (VARCHAR).

Examples

The following decodes a sequence of hexadecimal digits into the corresponding word:

SELECT HEX_DECODE_STRING('536E6F77666C616B65');

-----------------------------------------+
 HEX_DECODE_STRING('536E6F77666C616B65') |
-----------------------------------------+
 Snowflake                               |
-----------------------------------------+

Copy

The hexadecimal digits A-F can be uppercase or lowercase. The following statement uses lowercase letters but produces the same result as the preceding statement:

SELECT HEX_DECODE_STRING('536e6f77666c616b65');

-----------------------------------------+
 HEX_DECODE_STRING('536E6F77666C616B65') |
-----------------------------------------+
 Snowflake                               |
-----------------------------------------+

Copy

This shows another example of using HEX_DECODE_STRING:

Create a table and data:

CREATE TABLE binary_table (v VARCHAR, b BINARY);
INSERT INTO binary_table (v, b) 
    SELECT 'HELLO', HEX_DECODE_BINARY(HEX_ENCODE('HELLO'));

Copy

Now run a query to show that we can retrieve the data:

SELECT v, b, HEX_DECODE_STRING(TO_VARCHAR(b)) FROM binary_table;
+-------+------------+----------------------------------+
| V     | B          | HEX_DECODE_STRING(TO_VARCHAR(B)) |
|-------+------------+----------------------------------|
| HELLO | 48454C4C4F | HELLO                            |
+-------+------------+----------------------------------+

Copy


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4