Skip to content
Advertisement

Convert base 10 to base 2 in SQL Server for very large numbers

On SQL Server 2017 I have a base 10 number of type DECIMAL(38,0) which I need to convert to its base 2 representation.

This works fine for smaller numbers, but fails with the target order of magnitude:

The error message reads Msg 8115, Level 16, State 2, Line 2 Arithmetic overflow error converting expression to data type numeric.

I have also tried other approaches, but each has failed due to the magnitude of the original value. Any help with performing this conversion is greatly appreciated.

Advertisement

Answer

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement