简体   繁体   English

在SQL Server 2008 R2中存储“9999999.00000000”:将数字转换为数据类型数字的算术溢出错误

[英]Store “9999999.00000000” in SQL Server 2008 R2: Arithmetic overflow error converting numeric to data type numeric

I am trying to store 9999999.00000000 in SQL Server 2008 R2. 我试图在SQL Server 2008 R2中存储9999999.00000000 But, I was repeatedly facing this error 但是,我一再面对这个错误

Arithmetic overflow error converting numeric to data type numeric. 算术溢出错误将数字转换为数据类型数字。

Database column is of type DECIMAL(15,8) 数据库列的类型为DECIMAL(15,8)

Please advise me, how to solve it.. 请告诉我,如何解决..

C# Code: C#代码:

  loSqlParameters.Add(new SqlParameter("RUN", loOPERATION_TYPE.RUN.handleDBNull()));

  xxxx.Database.ExecuteSqlCommand("SPNAME".getSql(loSqlParameters), loSqlParameters.Cast<object>().ToArray())

SQL Server stored procedure: SQL Server存储过程:

 CREATE PROCEDURE [dbo].[SPNAME]  
     @RUN AS DECIMAL(15,8)
 AS    
 BEGIN 
    INSERT INTO TABLENAME (RUN) VALUES  (@RUN)
 END    

Table schema: 表模式:

Column Name     Data Type       Allow Nulls
RUN             decimal(15,8)    yes

This works correctly in SQL2008R2 when executed in SSMS. 在SSMS中执行时,这在SQL2008R2中正常工作。 If you run SQL Profiler and capture the SQL text being submitted by your application, you can check the stored procedure call including the parameter(s) being passed to the procedure. 如果运行SQL事件探查器并捕获应用程序提交的SQL文本,则可以检查存储过程调用,包括传递给过程的参数。 It is possible that the parameter value being sent is not what you are expecting to be sent. 发送的参数值可能不是您期望发送的参数值。

My SQL test code: 我的SQL测试代码:

    CREATE TABLE MyTable
    (
      Run decimal(15, 8) NULL
    );
    GO

    CREATE PROCEDURE dbo.spName
        @Run AS DECIMAL(15,8)
    AS    
    BEGIN 
      INSERT INTO MyTable(Run) VALUES(@Run)
    END;
    GO

    EXEC dbo.spName 9999999.00000000;
    GO

    SELECT *
    FROM MyTable;

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

相关问题 在SQL Server中将varchar转换为数值类型的算术溢出错误 - Arithmetic overflow error converting varchar to data type numeric in SQL Server SQL 8115将数值转换为数据类型numeric的算术溢出错误 - SQL 8115 Arithmetic overflow error converting numeric to data type numeric 如何解决SQL Server中的“将varchar转换为数据类型数值的算术溢出错误”错误? - How to solve “Arithmetic overflow error converting varchar to data type numeric” error in sql server? 错误:将数字转换为数据类型数字的算术溢出错误 - Error: Arithmetic overflow error converting numeric to data type numeric 将数字转换为数据类型数字的算术溢出错误 - Arithmetic overflow error converting numeric to data type numeric 在执行查询时将数值转换为数值类型的算术溢出错误 - Arithmetic overflow error converting numeric to data type numeric on query execution 在插入时将数字转换为数据类型数字的算术溢出错误 - Arithmetic overflow error converting numeric to data type numeric on insert 将数值转换为数值类型的算术溢出错误 - Arithmetic overflow error converting numeric to data type numeric 将数字转换为数据类型数字的算术溢出错误 - Arithmetic overflow error converting numeric to data type numeric 将数值转换为数值类型的算术溢出错误 - Arithmetic overflow error converting numeric to data type numeric
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM