HEX string to Binary bits

Database
Teradata Employee

HEX string to Binary bits

We have a HEX value and we need to parse it to a binary string.

I was looking at GETBIT and TO_NUMBER and FROM_BYTES, but I don't seem to be able to figure this out.  One of the errors I get is Conversion from BYTE and other data types is illegal.

We could do this as a UDF, but it seems that there should already be a function something like HEX_TO_BITS.

Any suggestions would be welcome.

1 REPLY
Junior Supporter

Re: HEX string to Binary bits

Hi:

If your HEX value is in a string (VARCHAR, CLOB) and yoy need a VARBYTE or BLOB as output, maybe TO_BYTES() is what you're looking for.

HTH.

Cheers.

Carlos.