hextoraw() function

The hextoraw() function interprets each pair of characters (left to right) in a varchar or nvarchar value as the hexadecimal code for an ASCII character and converts the hexadecimal sequence into a character string.

Syntax

The hextoraw() function has the following syntax:
varchar = hextoraw(varchar input);
nvarchar = hextoraw(varchar input, int unicode);

The input value specifies the varchar hexadecimal values to convert.

For nvarchar input, the unicode value specifies whether the input hexadecimal value uses UTF-8 or Unicode values. A value of 0 indicates that the string uses UTF-8 values, and a value of 1 indicates that the string uses Unicode values, which can be space-separated values. For nvarchar data, if you do not specify a Unicode value, the conversion result might be indeterminate.

Returns

The function returns a character string.

Example

SELECT hextoraw('68656C6C6f');
 HEXTORAW
----------
 hello
(1 row)