Quote:
|
Originally Posted by makonahalli
If I use ROUND() then I have to have database specific code in many places.
So, I am looking for a database wide setting if there is one.
|
There is an easy way to implement the ROUND function yourself, in a database wide way, and moreover without the overhead of a scalar function call:
1. Round a positive expression (expr) to the nearest integer value:
Code:
CAST(expr + 0.5 AS integer)
(Or just INT(expr + 0.5) .)
2. Round a positive expression (expr) to the nearest multiple of 0.01:
Code:
CAST(expr + 0.005 AS decimal(18, 2))
3. Round any (positive or negative) expression to the nearest integer:
Code:
case when expr > 0 then CAST(expr+0.5 AS int) else CAST(expr-0.5 AS int) end