Hex to Char conversion

Database
Enthusiast

Hex to Char conversion

Hello 

is there a way to convert hex to char in teradata ?

I understand this is a way but it onyl works when values are hardcoded, not when the source is a column value. 

SELECT   

           '312c30313637'  AS hex_value

         ,  _LATIN'312c30313637'XC AS char_value

Thanks

Abhishek

1 REPLY
Junior Contributor

Re: Hex to Char conversion

Hi Abhishek,

what's your Teradata release?

Since TD14 there are two new functions for Hex/Byte conversions.

If the characters in the Hex-string are ASCII you can use this:

FROM_BYTES(TO_BYTES(hex_value, 'base16'), 'ascii')

Or you could install some UDFs from the Unicode Tool Kit:

udf_LatinHex2Char(hex_value,'','') -- for Latin
udf_16BEHex2Char(hex_value, '','') -- for UTF16 Unicode