I have used decimal.round() method in c# which return as decimal.round (112.5) returns 112 but when I use round method in SQL server as select round (112.5,0) it return 113. What is the fault? Can anyone help me ?
Asked
Active
Viewed 205 times
3 Answers
1
SQL Server's ROUND
method rounds .5 up always while (in default mode) Math.Round
rounds to even (so 1.5 becomes 2, but 4.5 becomes 4). Round to even is commonly know as "Banker's Rounding".
Depending on which behaviour you want you can:
- Implement banker's rounding on SQL Server (see comment on the
ROUND
page on MSDN). - Use the option parameter on
Math.Round
to select a different rounding method.

Richard
- 106,783
- 21
- 203
- 265
1
You need to check the documentation for the decimal.round.
The integer that is nearest to the d parameter. If d is halfway between two integers, one of which is even and the other odd, the even number is returned.
https://msdn.microsoft.com/en-us/library/k4e2bye2(v=vs.110).aspx
The solution is to have a MidpointRounding parameter.
Please check this for simple samples: http://www.dotnetperls.com/math-round