开发者

Converting column decimal(18,8) to another column decimal(18,18)

I have a column which has decimal value of 18,8. I was asked to extend it to 18,18 to hold mor开发者_运维百科e places after ,.

ALTER TABLE [dbo].[TransakcjeGotowkowe]
ALTER COLUMN TransakcjeGotowkoweKwota decimal (18,18) NULL

Msg 8115, Level 16, State 8, Line 1
Arithmetic overflow error converting numeric to data type numeric.
The statement has been terminated.

I have also tried to do it by GUI. Nothing else changes just want to hold more data after ,.

Is there other way to do this ?


The Decimal datatype is made up of (precision, scale)

Precision is the total number of digits to the left AND the right of the decimal point.

Scale is the number of digits to the right of the decimal point.

If you want to increase the number of digits to the right to 18 you will need to increase the overall precision. In your case increase it by 10.

So you will need decimal(28,18)

MSDN Article on Precision & Scale


You would need to change it to 28,18 Your current column allows 10 digits to the left of the decimal point.

Changing it to 18,18 would only allow a range between +/-0.999999999999999999

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜