HEX returns the hexadecimal representation of the bytes that contain x. Its length is 2 * size(x) when x is the only parameter, i.e. HEX(x). When there is a second parameter, i.e. HEX(x,y), it returns a hexadecimal character string that contains x with y inserted between every set of eight characters. Its length is 2 * size(x) + ((size(x) - 1)/4).
The output character string for the data types Fixed Binary, Pointer, Offset, and Char Varying (applies to the leading 2-byte Fixed Bin size field) will be constructed in big-endian form.
The HEX function does not return an exact image of x in storage. If an exact image is required, use the HEXIMAGE built-in function.