Convert Hexadecimal to Byte(8) data type

Database
Enthusiast

Convert Hexadecimal to Byte(8) data type

Hi, I need to convert a string which is in Hexadecimal format to byte(8) data type. The query below works. But I don't know how to select the value out of the table and do the same conversion without the literal....

SELECT CAST('00000000000066E'xb AS byte(8)) as TS

TS
00-00-00-00-00-00-66-E0

For the query below, assuming TS has the same value in the literal above, how can I tell the query its in hex format to do the necessary conversion?

SELECT CAST(TS AS BYTE(8))

Thanks