Skip to content
Advertisement

Arithmetic overflow error while converting varchar to decimal datatype

I am trying to convert varchar(14) to Decimal(14,2). My code is something like

I am only getting Arithmetic overflow error message when the value of @varchar_variable is large (like ‘10000000000189’)

Why am I getting this error message for larger values ? Are values like 10000000000189 out of range for decimal datatype ? If yes, what is the range of decimal datatype in SQL.

Advertisement

Answer

You need to define Decimal(16,2) to convert varchar(14) to decimal. You can alternatively use Cast instead of Convert.

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