简体   繁体   English

为什么我不能在 sql server 表中插入小数?

[英]Why can't I insert a decimal into an sql server table?

I have a simple query:我有一个简单的查询:

INSERT INTO tblIndicators (RunID, EventTS, MA1t3) 
Values (65, '11/2/2012 2:25:00 AM', 1.0); 

I get this error message:我收到此错误消息:

Msg 8115, Level 16, State 8, Line 1 Msg 8115, Level 16, State 8, Line 1
Arithmetic overflow error converting numeric to data type numeric.将数字转换为数字数据类型时出现算术溢出错误。

The precision on the Decimal datatype is (8,8) . Decimal 数据类型的精度为(8,8) So whats the problem??所以有什么问题??

decimal (8, 8) means all 8 of your significant digits are to the right of the decimal point. decimal (8, 8)表示所有 8 位有效数字都在小数点右侧。 1.0 is too big. 1.0太大了。

Try decimal (8,2)尝试十进制 (8,2)

(8,8) doesn't leave you with any digits to the left of the . (8,8) 不会在 .

8,8 means can store at maximum 0.99999999 if you need to store a number like 12345678.12345678 you should declare : decimal (16,8) 8,8 表示最多可以存储 0.99999999 如果您需要存储像 12345678.12345678 这样的数字,您应该声明:十进制 (16,8)

Explaining this declaration : decimal ( {TotalDigits} , {DigitsToTheRight} )解释这个声明:十进制( {TotalDigits} , {DigitsToTheRight} )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM