rawtohex() function
The rawtohex() function converts a character string into an ASCII hexadecimal representation.
Syntax
varchar = rawtohex(varchar input);
nvarchar = rawtohex(nvarchar input, [int unicode]);
The input value specifies the
varchar or nvarchar string to
convert.
The unicode value specifies
whether to convert the input data
into UTF-8 or Unicode values. A value of 0 specifies
to convert the input string
into UTF-8 values, and a value of 1 specifies to
convert the string into Unicode
values. The default is 0.
Returns
The function returns an ASCII hexadecimal representation of a character string.
Example
select rawtohex('hello');
RAWTOHEX
------------
68656C6C6F
(1 row)