[原创]将 numeric 转换为数据类型 numeric 时出现算术溢出错误解决方法

问题:

执行存储过程报:

将 numeric 转换为数据类型 numeric 时出现算术溢出错误。

问题原因:

存储过程中创建临时表时,临时表的字段类型长度小于后续更新的值的长度导致

转换异常

解决办法:

创建临时表时利用cast将字段类型转换为长度符合插入值的类型

代码如下:

 

	SELECT Identifier,Stock_State,Supplier_ID,Buyer_ID,Goods_ID,Unit_ID,Tax_ID,
	cast(0 as money) as Start_Amount,cast(0 as money) as Into_Amount,cast(0 as money) as Outlay_Amount,
	Stock_Money as End_Amount,Into_Price,Tax_Money,
	@Start_Date as Start_Date,@End_Date as End_Date,cast(0 as decimal(18,4)) as Start_Stock,
	cast(0 as decimal(18,4)) as Into_Stock,cast(0 as decimal(18,4)) as Outlay_Stock,Total_Stock as End_Stock,
	Tax_Value,Batch_Code,Supplier,Supplier_Secrecy,Buyer,
	Goods_Name,Physical,Chemistry,Detail_Params,Stock_Unit,Tax_Rate
	INTO #temp_AccountsInventory
	FROM
		Stock_Details
赞(0) 打赏
分享到: 更多 (0)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏