简体   繁体   English

错误:将varchar转换为数值类型的算术溢出错误

[英]Error: Arithmetic overflow error converting varchar to data type numeric

select distinct f1.[record] from [field] f1 where ((ABS((Cast((Select [value] from dbo.getFieldTopTable(f1.[record], 'ar_essay1_read1')) as Decimal(5,3))) - (Cast((select [value] from dbo.getFieldTopTable(f1.[record], 'ar_essay1_read2')) as Decimal(5,3)))) > 1.0) 
or (ABS((Cast((Select [value] from dbo.getFieldTopTable(f1.[record], 'ar_essay2_read1')) as Decimal(5,3))) - (Cast((select [value] from dbo.getFieldTopTable(f1.[record], 'ar_essay2_read2')) as Decimal(5,3)))) > 1.0) 
or (ABS((Cast((Select [value] from dbo.getFieldTopTable(f1.[record], 'ar_essay3_read1')) as Decimal(5,3))) - (Cast((select [value] from dbo.getFieldTopTable(f1.[record], 'ar_essay3_read2')) as Decimal(5,3)))) > 1.0) 
or (ABS((Cast((Select [value] from dbo.getFieldTopTable(f1.[record], 'ar_essay4_read1')) as Decimal(5,3))) - (Cast((select [value] from dbo.getFieldTopTable(f1.[record], 'ar_essay4_read2')) as Decimal(5,3)))) > 1.0))

The data stored in these fields is setup at real and ranges in value from .001 to 4.00 (should it be int?) 这些字段中存储的数据是真实设置的,值范围从.001到4.00(应该是int吗?)

We're just trying to find records where the difference between 2 scores is greater than 1 我们正试图查找2个分数之差大于1的记录

We've also just tried the cast _ to decimal with no precision and it leaves out records that should be in the query... 我们还尝试了将_强制转换为十进制,但没有精确度,并且省略了应该在查询中的记录...

Is there something we're not thinking about? 有什么我们不考虑的吗?

You shouldn't need to cast these values at all, the problem is most likely the datatype of the value returned by your dbo.getFieldTopTable() function. 您根本不需要dbo.getFieldTopTable()这些值,问题很可能是dbo.getFieldTopTable()函数返回的值的数据类型。 Ensure that it is returning a value with decimals. 确保它返回带小数的值。

Digits to the right of the decimal place should not cause a truncation error. 小数点右边的数字不应引起截断错误。 Try DECIMAL(9,3). 尝试DECIMAL(9,3)。 That consumes the same memory as DECIMAL(5,3). 那消耗的内存与DECIMAL(5,3)相同。

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

相关问题 算术溢出错误将varchar转换为数据类型numeric -error - Arithmetic overflow error converting varchar to data type numeric -error 错误:将数字转换为数据类型varchar的算术溢出错误 - Error : Arithmetic overflow error converting numeric to data type varchar 将数字转换为数据类型varchar的算术溢出错误 - Arithmetic overflow error converting numeric to data type varchar 将varchar转换为数值类型-VBA的算术溢出错误 - Arithmetic overflow error converting varchar to data type numeric -VBA 在存储过程中将varchar转换为数值类型的算术溢出错误 - Arithmetic overflow error converting varchar to data type numeric in stored procedure 将varchar转换为数值类型的算术溢出错误 - Arithmetic overflow error converting varchar to data type numeric 将 varchar 转换为数据类型 numeric CASE 语句的算术溢出错误 - Arithmetic overflow error converting varchar to data type numeric CASE statement 将 varchar 转换为数据类型 numeric 的算术溢出错误 - Arithmetic overflow error converting varchar to data type numeric 将varchar转换为数值数据类型的算术溢出错误? - Arithmetic overflow error converting varchar to data type numeric? 在SQL Server中将varchar转换为数值类型的算术溢出错误 - Arithmetic overflow error converting varchar to data type numeric in SQL Server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM