• sknox (12/4/2009)


    Steve Eckhart (12/4/2009)


    select cast(1.67574 as decimal(38,10)) = 1.675400000 which has precision 6 and scale 10, right?

    and

    select cast(10000 as decimal(38,10)) = 10000.0000000000 which has precision 1 and scale 10, right?

    wrong, and wrong. Because you're explicitly casting to decimal(38,10), both of your results have precision of 38 and scale of 10 even though they don't apparently require it. SQL server will not narrow the precision and scale of an explicitly cast decimal result.

    I'm struggling here.

    Surely that's exactly what SQLServer is doing?

    Either way, the explanation attached to the QotD doesn't seem to attempt to explain it - and I'm not surprised!