tags:

views:

236

answers:

1

So I'm dividing an integer by a decimal, and storing the result in a decimal column. However, it always drops the fractional component(the part after the decimal point). If I multiply the result by 10 or 100 I get a more accurate result, but dividing again drops the fractional part again.

The two fields I've inserted into were a precision 5, scale 0 decimal and a precision 5, scale 3 decimal.

I've also tried casting the integer into a decimal and that doesn't make a difference, neither does multiplying by 1.0.

I'm out of ideas or tricks to try.

Thanks, Buzkie

A: 

Turns out I was casting incorrectly. After doing using the correct format

CAST(int AS DECIMAL(5,3))

it worked. I had left off the precision and scale before.

Buzkie