What is UNICODE() function in Snowflake ?

Are you looking to find what is the UNICODE() function within the Snowflake cloud data warehouse or maybe you are looking for a solution to use the unicode functions in the Snowflake? If you are looking for any of these problem solutions then you have landed on the correct page. I will also show you what and how to use UNICODE() function. I will explain the UNICODE() function by taking a practical examples. So don’t waste time let’s start step by step guide to understand what is the UNICODE() expression in detail.

What is UNICODE() Function

UNICODE() function is used to returns the unicode point for the first unicode character in a string. If the string is empty then the returned value is zero (0).

UNICODE syntax in Snowflake

-- Syntax : 

UNICODE( Input )

UNICODE() Argument Details :

InputString value ( Mandatory )
OutputValue of integer

Input :

The String for which the Unicode code point for the first character in the string is returned.

Returns :

The returned data type value is an Integer.

UNICODE Example in Snowflake :

select column1, unicode(column1), char(unicode(column1))
from values('a'), ('\u2744'), ('cde'), (''), (null);

-- Query Results

+---------+------------------+------------------------+
| COLUMN1 | UNICODE(COLUMN1) | CHAR(UNICODE(COLUMN1)) |
|---------+------------------+------------------------|
| a       |               97 | a                      |
| ❄      |            10052 | ❄                      |
| cde     |               99 | c                      |
|         |                0 |                        |
| NULL    |             NULL | NULL                   |
+---------+------------------+------------------------+

As we can see the above example we got the Unicode code depending on the characters. We can see for the data ‘cde’ we got Unicode code as 99 because we will get the Unicode code of first character in a string.

Unicode Snowflake official Documentation Link

Final Thoughts

In this article we have learned about UNICODE() function and uses with the examples explained clearly. I have also covered different scenario with practical example that could be possible. I hope the information that was provided is helped in gaining the knowledge.

Please share your comments and suggestions in the comment section below and I will try to answer all your queries as time permits.

How to ALTER TABLE in Snowflake with Practical Example

How to create Task in Snowflake

How to create table dynamically in Snowflake?

Leave a Comment