简体   繁体   English

在插入时将数字转换为数据类型数字的算术溢出错误

[英]Arithmetic overflow error converting numeric to data type numeric on insert

I am having trouble with this query that shows Arithmetic overflow error. 我在显示算术溢出错误的查询时遇到了麻烦。

INSERT INTO seed_health_testing_form (seedlotno, modeoftesting, datetested, 
    datecollected, placecollected, sampleno, germination1, germination2, 
    germination3, germination4, germination5, germination6, germination7, 
    germination8, germination9, germination10, remarks) 
VALUES ( 'A00075', 'GTest', '2/14/2013', 
    '2/19/2013', 'Laguna', 0, 50.00, 50.00, 
    50.00, 50.00, 0.00, 0.00, 0.00, 
    0.00, 0.00, 0.00, '')

Table Design 餐桌设计

[id]                [int]       IDENTITY(1,1) PRIMARY KEY NOT NULL
[seedlotno]         [varchar](50)   NULL
[modeoftesting]     [varchar](100)  NULL
[datetested]        [datetime]      NULL
[datecollected]     [datetime]      NULL
[placecollected]    [varchar](100)  NULL
[sampleno]          [int]           NULL
[germination1]      [decimal](3, 2) NULL
[germination2]      [decimal](3, 2) NULL
[germination3]      [decimal](3, 2) NULL
[germination4]      [decimal](3, 2) NULL
[germination5]      [decimal](3, 2) NULL
[germination6]      [decimal](3, 2) NULL
[germination7]      [decimal](3, 2) NULL
[germination8]      [decimal](3, 2) NULL
[germination9]      [decimal](3, 2) NULL
[germination10]     [decimal](3, 2) NULL
[remarks]           [varchar](1000) NULL

I tried breaking the INSERT query line by line to trace where the error was but it always point to Line 1. Still I can't find where my problem is. 我尝试逐行打破INSERT查询以跟踪错误的位置,但它始终指向第1行。仍然无法找到我的问题所在。

All of your [decimal](3, 2) data types are the issue. 所有[decimal](3, 2)数据类型都是问题。

The (3,2) tells you that the number can have a precision of 3 digits total, with 2 digits being reserved for the decimal portion. (3,2)告诉您该数字的总精度为3位数,其中2位数保留给小数部分。

Thus, you only have 1 digit available to store values like 50 , which causes the overflow. 因此,您只有1位可用于存储值50 ,这会导致溢出。

See the decmial datatype documentation for more information. 有关更多信息,请参见decmial数据类型文档

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

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