Convert Between Binary and Numeric or Decimal Types

When you convert a binary or varbinary type to numeric or decimal, you must specify the “00” or “01” values after the “0x” digit; otherwise, the conversion fails.

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.

For example, to convert the following binary data to numeric use:
select convert(numeric
(38, 18),0x000000000000000006b14bd1e6eea0000000000000000000000000000000)
To convert the same numeric data back to binary use:
select convert(binary,convert(numeric(38, 18), 123.456))