[英]Arithmetic overflow error converting numeric to data type numeric
I have executed this query on 2 different databases: 我已经在2个不同的数据库上执行了此查询:
Update table1 set PresencePayFactor = cast(30 as decimal (4,2))/ 30 更新表1设置PresencePayFactor = cast(30为十进制(4,2))/ 30
it is working on one but not on the other. 它在一个方面起作用,但在另一方面却不起作用。 the 2 databases are sql server 2008 R2
2个数据库是sql server 2008 R2
it is giving the following error "Arithmetic overflow error converting numeric to data type numeric." 它给出以下错误“将数字转换为数据类型数字的算术溢出错误”。
What may be the problem? 可能是什么问题?
Is NUMERIC_ROUNDABORT set differently between the two? 两者之间的NUMERIC_ROUNDABORT是否设置不同?
SET NUMERIC_ROUNDABORT OFF
GO
Declare @TestTable Table ( PresencePayFactor decimal(4,2) null )
Insert @TestTable( PresencePayFactor )
Select Cast( 30 As decimal(4,2) ) / 30
GO
-- No error
SET NUMERIC_ROUNDABORT ON
GO
Declare @TestTable Table ( PresencePayFactor decimal(4,2) null )
Insert @TestTable( PresencePayFactor )
Select Cast( 30 As decimal(4,2) ) / 30
-- Arithmetic overflow error converting numeric to data type numeric.
SET NUMERIC_ROUNDABORT (Transact-SQL) SET NUMERIC_ROUNDABORT(Transact-SQL)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.