I'm trying to determine the best way to truncate or drop extra decimal places in SQL without rounding. For example:
declare @value decimal(18,2)
set @value = 123.456
This will auto round @Value to be 123.46....which in most cases is good. However, for this project I don't need that. Is there a simple way to truncate the decimals I don't need? I know I can use the left() function and convert back to a decimal...any other ways?
Another truncate with no rounding solution and example.
I think you want only the decimal value, in this case you can use the following:
Here's the way I was able to truncate and not round:
returns 100.0010
And your example:
returns 123.450
Now if you want to get rid of the ending zero, simply cast it:
returns 123.45
Mod(x,1)
is the easiest way I think.