Arithmetic overflow error converting numeric data to a numeric data type

I executed this query in two different databases:

Refresh table 1 PresencePayFactor = cast (30 as decimal (4,2)) / 30

he works on one, but not on the other. 2 SQL Server 2008 R2 Databases

it gives the following error, "Arithmetic overflow error converting numeric data to numeric data."

What could be the problem?

+4
source share
1 answer

Is NUMERIC_ROUNDABORT set differently between the two?

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)

+2
source

All Articles