简体   繁体   English

算术溢出错误将varchar转换为数据类型numeric -error

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

I am trying to concat the following columns 我正在尝试合并以下各列

c.coursec + ' ' +  ms.sectionn, 

ms.secitonn is a (decimal 3,0) ms.secitonn是一个(十进制3,0)

Thus I am getting an error: 因此,我得到一个错误:

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

c.coursec = 187C
ms.sectionn = 2
needed results is 187c-2 

I assume I must do some kind of cast or convert? 我认为我必须进行某种类型的转换或转换?

You are correct, a convert will allow your string to concatenate. 您是正确的, 转换将允许您的字符串连接。

c.coursec + ' ' +  Convert(varchar(50), ms.sectionn), 

Cast is valid as well: 强制转换也有效:

c.coursec + ' ' +  CAST( ms.sectionn AS varchar(50)), 

Depending on the type of c.coursec you'll want to adjust your convert parameter. 根据c.coursec的类型,您需要调整convert参数。 For example if c.coursec is nvarchar then modifying the cast would be appropriate. 例如,如果c.coursecnvarchar则修改演员表将是适当的。

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

相关问题 错误:将数字转换为数据类型varchar的算术溢出错误 - Error : Arithmetic overflow error converting numeric to data type varchar 错误:将varchar转换为数值类型的算术溢出错误 - Error: Arithmetic overflow error converting varchar to data type numeric 将数字转换为数据类型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