A quote from
http://classicasp.aspfaq.com/general/why-does-4/5-0.html:
"Why does 4 / 5 = 0?
SQL Server
You may be startled to see the result of this calculation in SQL Server:
SELECT 4 / 5
-----------
0
(1 row(s) affected)
This is because SQL Server is performing integer division... which ignores decimals / fractions / remainders. There are a couple of ways you can force the behavior you really want:
SELECT 4.0 / 5
SELECT 4 * 1.0 / 5
SELECT CAST(4 AS DECIMAL(5,1)) / 5"
There are many JET (MS Access) queries I should translate to T-SQL. I'd like to avoid those 3 ways.
Is there some sql server 2005 setting I should set to force the division to be a floating point division instead of an integer division when both denominator & numerator are integers ?
Start Free Trial