Showing posts with label overflow. Show all posts
Showing posts with label overflow. Show all posts

Wednesday, 7 March 2012

Confusing arithmetic overflow error

I have a numeric column whoose precision is 7 and scale is 3.
My first question is how come the length is reported as 5 in Enterprise
Managaer?
Secondly, whilst trying to update values in these columns I get
Server: Msg 8115, Level 16, State 8, Line 1
Arithmetic overflow error converting numeric to data type numeric.
The statement has been terminated.
...for values such as -16942.18, -16939.59, 16935.46, 16939.59. Surely, any
of these values should fit nicely into my defined data type? Why is this
occuring?
Cheers,
elzikoThe length is reported as 5 because that's the number of bytes that the
datatype occupies.
Precision 7, scale 3 = XXXX.YYY
4 digits to the left of the decimal point, 3 to the right.
-16942.18 has 5 to the left, 2 to the right. That's why it's failing.
"elziko" <elziko@.NOTSPAMMINGyahoo.co.uk> wrote in message
news:OC9W741jEHA.592@.TK2MSFTNGP11.phx.gbl...
> I have a numeric column whoose precision is 7 and scale is 3.
> My first question is how come the length is reported as 5 in Enterprise
> Managaer?
> Secondly, whilst trying to update values in these columns I get
> Server: Msg 8115, Level 16, State 8, Line 1
> Arithmetic overflow error converting numeric to data type numeric.
> The statement has been terminated.
> ...for values such as -16942.18, -16939.59, 16935.46, 16939.59. Surely,
any
> of these values should fit nicely into my defined data type? Why is this
> occuring?
> --
> Cheers,
> elziko
>|||Oh it appears I counted four to the left... stupid me! Sorry & thanks!|||If you read in BOL (decimal and numeric) there is a table that specifies how
many bytes to store numeric data based on the precision.
As for your overflow this is occurring, because you ask for 3 digits to the
right of the decimal point to be stored (scale), but the total length of the
the number to only be 7 digits long (precision). Therefore the numbers you
are trying to use really have 8 digit precision (i.e -16942.18, is
really -16942.180).
----
----
-
Need SQL Server Examples check out my website
http://www.geocities.com/sqlserverexamples
"elziko" <elziko@.NOTSPAMMINGyahoo.co.uk> wrote in message
news:OC9W741jEHA.592@.TK2MSFTNGP11.phx.gbl...
> I have a numeric column whoose precision is 7 and scale is 3.
> My first question is how come the length is reported as 5 in Enterprise
> Managaer?
> Secondly, whilst trying to update values in these columns I get
> Server: Msg 8115, Level 16, State 8, Line 1
> Arithmetic overflow error converting numeric to data type numeric.
> The statement has been terminated.
> ...for values such as -16942.18, -16939.59, 16935.46, 16939.59. Surely,
any
> of these values should fit nicely into my defined data type? Why is this
> occuring?
> --
> Cheers,
> elziko
>

Confusing arithmetic overflow error

I have a numeric column whoose precision is 7 and scale is 3.
My first question is how come the length is reported as 5 in Enterprise
Managaer?
Secondly, whilst trying to update values in these columns I get
Server: Msg 8115, Level 16, State 8, Line 1
Arithmetic overflow error converting numeric to data type numeric.
The statement has been terminated.
...for values such as -16942.18, -16939.59, 16935.46, 16939.59. Surely, any
of these values should fit nicely into my defined data type? Why is this
occuring?
Cheers,
elziko
The length is reported as 5 because that's the number of bytes that the
datatype occupies.
Precision 7, scale 3 = XXXX.YYY
4 digits to the left of the decimal point, 3 to the right.
-16942.18 has 5 to the left, 2 to the right. That's why it's failing.
"elziko" <elziko@.NOTSPAMMINGyahoo.co.uk> wrote in message
news:OC9W741jEHA.592@.TK2MSFTNGP11.phx.gbl...
> I have a numeric column whoose precision is 7 and scale is 3.
> My first question is how come the length is reported as 5 in Enterprise
> Managaer?
> Secondly, whilst trying to update values in these columns I get
> Server: Msg 8115, Level 16, State 8, Line 1
> Arithmetic overflow error converting numeric to data type numeric.
> The statement has been terminated.
> ...for values such as -16942.18, -16939.59, 16935.46, 16939.59. Surely,
any
> of these values should fit nicely into my defined data type? Why is this
> occuring?
> --
> Cheers,
> elziko
>
|||Oh it appears I counted four to the left... stupid me! Sorry & thanks!
|||If you read in BOL (decimal and numeric) there is a table that specifies how
many bytes to store numeric data based on the precision.
As for your overflow this is occurring, because you ask for 3 digits to the
right of the decimal point to be stored (scale), but the total length of the
the number to only be 7 digits long (precision). Therefore the numbers you
are trying to use really have 8 digit precision (i.e -16942.18, is
really -16942.180).
----
-
Need SQL Server Examples check out my website
http://www.geocities.com/sqlserverexamples
"elziko" <elziko@.NOTSPAMMINGyahoo.co.uk> wrote in message
news:OC9W741jEHA.592@.TK2MSFTNGP11.phx.gbl...
> I have a numeric column whoose precision is 7 and scale is 3.
> My first question is how come the length is reported as 5 in Enterprise
> Managaer?
> Secondly, whilst trying to update values in these columns I get
> Server: Msg 8115, Level 16, State 8, Line 1
> Arithmetic overflow error converting numeric to data type numeric.
> The statement has been terminated.
> ...for values such as -16942.18, -16939.59, 16935.46, 16939.59. Surely,
any
> of these values should fit nicely into my defined data type? Why is this
> occuring?
> --
> Cheers,
> elziko
>

Confusing arithmetic overflow error

I have a numeric column whoose precision is 7 and scale is 3.
My first question is how come the length is reported as 5 in Enterprise
Managaer?
Secondly, whilst trying to update values in these columns I get
Server: Msg 8115, Level 16, State 8, Line 1
Arithmetic overflow error converting numeric to data type numeric.
The statement has been terminated.
...for values such as -16942.18, -16939.59, 16935.46, 16939.59. Surely, any
of these values should fit nicely into my defined data type? Why is this
occuring?
--
Cheers,
elzikoThe length is reported as 5 because that's the number of bytes that the
datatype occupies.
Precision 7, scale 3 = XXXX.YYY
4 digits to the left of the decimal point, 3 to the right.
-16942.18 has 5 to the left, 2 to the right. That's why it's failing.
"elziko" <elziko@.NOTSPAMMINGyahoo.co.uk> wrote in message
news:OC9W741jEHA.592@.TK2MSFTNGP11.phx.gbl...
> I have a numeric column whoose precision is 7 and scale is 3.
> My first question is how come the length is reported as 5 in Enterprise
> Managaer?
> Secondly, whilst trying to update values in these columns I get
> Server: Msg 8115, Level 16, State 8, Line 1
> Arithmetic overflow error converting numeric to data type numeric.
> The statement has been terminated.
> ...for values such as -16942.18, -16939.59, 16935.46, 16939.59. Surely,
any
> of these values should fit nicely into my defined data type? Why is this
> occuring?
> --
> Cheers,
> elziko
>|||Oh it appears I counted four to the left... stupid me! Sorry & thanks!|||If you read in BOL (decimal and numeric) there is a table that specifies how
many bytes to store numeric data based on the precision.
As for your overflow this is occurring, because you ask for 3 digits to the
right of the decimal point to be stored (scale), but the total length of the
the number to only be 7 digits long (precision). Therefore the numbers you
are trying to use really have 8 digit precision (i.e -16942.18, is
really -16942.180).
--
----
----
-
Need SQL Server Examples check out my website
http://www.geocities.com/sqlserverexamples
"elziko" <elziko@.NOTSPAMMINGyahoo.co.uk> wrote in message
news:OC9W741jEHA.592@.TK2MSFTNGP11.phx.gbl...
> I have a numeric column whoose precision is 7 and scale is 3.
> My first question is how come the length is reported as 5 in Enterprise
> Managaer?
> Secondly, whilst trying to update values in these columns I get
> Server: Msg 8115, Level 16, State 8, Line 1
> Arithmetic overflow error converting numeric to data type numeric.
> The statement has been terminated.
> ...for values such as -16942.18, -16939.59, 16935.46, 16939.59. Surely,
any
> of these values should fit nicely into my defined data type? Why is this
> occuring?
> --
> Cheers,
> elziko
>