In binary and varbinary data strings, the first two digits after “0x” represent the binary type: “00” represents a positive number and “01” represents a negative number. When you convert a binary or varbinary type to numeric or decimal, be sure to specify the “00” or “01” values after the “0x” digit; otherwise, the conversion fails.
For example, here is how to convert the following binary data to numeric:
select convert(numeric (38, 18),0x000000000000000006b14bd1e6eea0000000000000000000000000000000)
---------------------- 123.456000000000000000
This example converts the same numeric data back to binary:
select convert(binary,convert(numeric(38, 18), 123.456))
-------------------------------------------------------------- 0x000000000000000006b14bd1e6eea0000000000000000000000000000000