We are trying to find a way to truncate (i.e. drop all the extra decimal places) in SQL Server. We do not want to have the number rounded at all just truncated as is.
For example:
declare @variable decimal(18,2)
set @variable = 123.456
This will cause the value stored in @variable to be 123.46 (the rounded variable). However this is not what we want. We want the value to be stored as 123.45. Is there an efficient way to remove the decimal places that I do not need in SQL SERVER?
Hello, yes there is a optional third parameter in the round function in SQL SERVER that will truncate a value instead of rounding the value. When this third parameter is not equal to 0 (the default value) the function will truncate.
For example
select round(123.456, 2, 1)