Introduction
Today and test communication a percentage calculation method encountered a problem, I used in the stored procedure strong to cast (32.678 as Decimal (5,1)) I think this method will only retain a decimal place, I give the test reply is I did not use the rounding function, the data is not rounded, The test says that the data that they have verified is rounded. Thought of here so I tried again every compute point of the stored procedure, only to discover this problem.
ROUND
We would definitely prefer the round function if the data type of the field is decimal (18,10) When rounding is used and the decimal point is reserved, and a lot of 0 will appear after rounding.
Cast and convert
In fact, I did not intend to use a strong turn round the results, just to get the data that meet my requirements, today only found that the two strong turn will also round the results, that is, the following three statements will return the same result value
Select ROUND (32.678,1) --32.700select CAST (32.678 as DECIMAL (5,1)) --32.7select convert (NUMERIC (5,1), 32.678 ) --32.7
SQL Server rounding do you have any other methods besides using round?