• Oleg Netchaev (8/3/2010)


    mtillman-921105 (8/3/2010)


    I think that this "feature" should be changed. Just because two numbers are integers, why assume the answer should also be an integer? :angry:

    I would like to disagree with this. The "feature" happens to be default, consistent behaviour in many programming languages. Try this is C#:

    int i = 5, j = 3;

    Console.WriteLine(i / j);

    The above happily prints 1 to the console window. Why would anyone think that T-SQL should behave differently?

    Very good question Hugo, thank you. It does not happen too often to be able to answer your QotD right off the bat without thinking much. 🙂

    Oleg

    Oleg, first, my standard is my calculator and if I put in 5/3, it shows 1.66666666.

    Second, logically, 5 / 3 <> 1. It is actually closer to 2. So SQL is returning a false statement.

    Third, us humans don't think this way typically I don't believe (thus, the good main question here). Since SQL is our tool, we should dictate how it works rather than vice-versa.

    However, I can accept your line of reasoning, but I still don't agree.

    The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge. - Stephen Hawking