MSSQL behavior: I need to round instead of truncation when number scale is exceeded
-
Hi! On SQL server, when I try to save value 0.4569 to a decimal(9,3) column, the value is truncated. It becomes 0.456. It there a way how to change this behavior of sql server? I would like such numbers to be rounded (to 0.457 in my example) instead of truncating them. Is there some global setting for this? Thanks!
-
Hi! On SQL server, when I try to save value 0.4569 to a decimal(9,3) column, the value is truncated. It becomes 0.456. It there a way how to change this behavior of sql server? I would like such numbers to be rounded (to 0.457 in my example) instead of truncating them. Is there some global setting for this? Thanks!
Try the round function[^]
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
-
Try the round function[^]
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
-
Hi! On SQL server, when I try to save value 0.4569 to a decimal(9,3) column, the value is truncated. It becomes 0.456. It there a way how to change this behavior of sql server? I would like such numbers to be rounded (to 0.457 in my example) instead of truncating them. Is there some global setting for this? Thanks!
Only setting that affects rounding that I know of is "NUMERIC_ROUNDABORT". It says "rounded" and not "truncated" in the documentation[^].
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)
-
Hi! On SQL server, when I try to save value 0.4569 to a decimal(9,3) column, the value is truncated. It becomes 0.456. It there a way how to change this behavior of sql server? I would like such numbers to be rounded (to 0.457 in my example) instead of truncating them. Is there some global setting for this? Thanks!
You could always add 0.0005 to your numbers before saving them... ;P