# Why an overflow?

• bozo7

Ten Centuries

Points: 1278

I am confused and I must be missing something really obvious here. Why does this syntax:

declare @Calc decimal(3,1), @CountDec decimal(3,1), @TotalDec decimal(3,1);

set @CountDec = 145.5;

set @totaldec = 165.5;

set @Calc = (@CountDec/@TotalDec) * 100;

select @Calc;

produce this result:

Server: Msg 8115, Level 16, State 8, Line 2

Arithmetic overflow error converting numeric to data type numeric.

Server: Msg 8115, Level 16, State 8, Line 3

Arithmetic overflow error converting numeric to data type numeric.

(1 row(s) affected)

I have a group of stored procs that worked for a while and have now quit working. What am I missing?

Thanks ,

Ross • Allen Cui-55137

SSC Guru

Points: 51653

You only secifie the maximum total number (3) of decimal digits that can be stored, both to the left and to the right of the decimal point. The maxium number can only be 99.9

• bozo7

Ten Centuries

Points: 1278

Thanks,

I just re-read BOL for the fourth time and the light clicked on in my head. At that moment I go the email that you had replied. Read your reply and the puzzle was complete.

Thanks,

Ross Viewing 3 posts - 1 through 3 (of 3 total)