Department using Convert Sql Server

Possible duplicate:
Accuracy, scale, amount, split .. Truncation

I have a question. I programmed a function, but I am having problems when I divide 2 numbers using convert. Here is an example:

Declare @A Numeric(18,6) Declare @B Numeric(18,6) Set @A = 1 Set @B = 130 

If I performed the following query, the result is: 0.007692307692307692

 Select Convert(Decimal(30,18),@A / @B) 

But if I do, the result: 0.007692300000000000 (loss of decimal places)

 Select Convert(Decimal(30,18),Convert(Decimal(30,18),@A) / Convert(Decimal(30,18),@B)) 

Can someone explain why I am losing decimal numbers if I use the same precision and scale?

+4
source share

All Articles