May 4, 2015 at 2:49 am
The following statement
select ROUND(9.5, 0)
gives error:
Msg 8115, Level 16, State 2, Line 1
Arithmetic overflow error converting expression to data type numeric.
at SQLExpress 2005 and SQLExpress2014 versions
the same error for any number between 9.5 to 9.9999
May 4, 2015 at 2:57 am
Weird. I suspect because Round returns numeric of the same precision and scale as its input, and 10 won't fit into a numeric (2,1)
As a workaround:
select ROUND(CAST(9.5 AS Numeric(3,1)), 0)
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
May 4, 2015 at 3:24 am
Thanks for the workaround :-),
yes the same error for 99.5 or 999.5.
May 4, 2015 at 3:27 am
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply