• Phil Parkin (6/17/2016)


    Nice example, Luis.

    One thing which is unclear to me in all this is how SQL Server determines precision and scale for a given calculation. For example

    1.00 / 7.1

    which, according to my calculator, is

    0.14084507042253521126760563380282 .....

    Yet SQL Server calculates it as

    0.1408450000000000000000000000000000000 (precision 8, scale 6)

    We are nowhere near the 38 absolute maximum here. So where does the scale 6 come from?

    It's because of the precision you defined for the source values.

    Indicate that more digits are known in those numbers and you'll get better precision in the output:

    SELECT 1.0000000000000000000000000000000000000 / 7.1

    returns:

    0.140845070422535211267605633802816901

    _____________
    Code for TallyGenerator