Just got badly bitten by MS SQL when tried to save a large value 11545545645.00
into a column with type numeric(16, 8)
.
当尝试将大值11545545645.00保存到类型为numeric(16,8)的列中时,被MS SQL严重咬了。
Is there a way to figure out the max value such a numeric column can have based on its precision and scale?
有没有办法根据其精度和比例计算出这样一个数字列可以有的最大值?
1 个解决方案
#1
10
The maximum total number of decimal digits that can be stored, both to the left and to the right of the decimal point. The precision must be a value from 1 through the maximum precision of 38. decimal and numeric (Transact-SQL)
小数点左侧和右侧可存储的最大小数位数。精度必须是从1到最大精度为38的值。十进制和数字(Transact-SQL)
So in your case numeric(16, 8) you have 8 (16 - 8
) digits left before the decimal point
所以在你的情况下数字(16,8)你在小数点前面有8(16 - 8)位数
#1
10
The maximum total number of decimal digits that can be stored, both to the left and to the right of the decimal point. The precision must be a value from 1 through the maximum precision of 38. decimal and numeric (Transact-SQL)
小数点左侧和右侧可存储的最大小数位数。精度必须是从1到最大精度为38的值。十进制和数字(Transact-SQL)
So in your case numeric(16, 8) you have 8 (16 - 8
) digits left before the decimal point
所以在你的情况下数字(16,8)你在小数点前面有8(16 - 8)位数