Bernardo Botelho
Bernardo Botelho

Reputation: 686

Arithmetic Overflow on numeric AVG() SQL Server

Why does

select avg(cast(5 as numeric(15,2))) 

returns "Arithmetic overflow error converting numeric to data type numeric."?

Documentation states the following about the avg function:

input: decimal category (p, s)

output: decimal(38, s) divided by decimal(10, 0)

I don't really see how it would overflow.

Upvotes: 0

Views: 1129

Answers (1)

Bernardo Botelho
Bernardo Botelho

Reputation: 686

Found out the problem:

Database Properties > Options > Numeric Round-Abort was ON.

When set to off the query executed with success.

Upvotes: 2

Related Questions