The following example will help you.
With rounding:
select ROUND(55.4567, 2, 0) -- Returns 55.4600 select CAST(55.4567 as decimal(38, 2)) -- Returns 55.46
Without rounding:
select ROUND(55.4567, 2, 1) -- Returns 55.4500 select CAST(ROUND(55.4567, 2, 1) as decimal(38, 2)) -- Returns 55.45
or
Use the Str()
function. It takes three arguments (number, number of characters to display, and number of decimal places to display
Select Str(12345.6789, 12, 3)
displays: "12345.679" (3 spaces, 5 digits 12345, decimal point and three decimal digits (679). - rounded if necessary to trim
for a total of 12 characters, with 3 to the right of the decimal point.
source share