• ScottPletcher (4/9/2013)


    SQL will automatically cast the result to the receiving data type; cast will automatically round.

    I've always thought it truncated the decimals instead of rounding them (which also happens). Afters reading BOL, I found this under CAST and CONVERT

    When you convert data types that differ in decimal places,

    sometimes the result value is truncated

    and at other times it is rounded. The following table shows the behavior.

    FromToBehavior

    numericnumericRound

    numericintTruncate

    numericmoneyRound

    moneyintRound

    moneynumericRound

    floatintTruncate

    floatnumericRound

    floatdatetimeRound

    datetimeintRound

    Thank you for making me learn something new.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2