-
Dividing two numbers truncates after 4 decimal places
I have two fields - both defined as money.
When I divide them, SQL Server truncates the result after the 4th decimal point.
So SQL Server says: 370.45 / 3,391,517.85 = 0.0001
I want to achieve: 370.45 / 3,391,517.85 = 0.00010922837... etc.
The field the result is going into is defined as decimal(20,18)
I've tried using "cast(1stmoneyfield as decimal(20,18)) / cast(2ndmoneyfield as decimal(20,18)) as dividednumber", but SQL Server reports back errors about null values and Arithmetic overflow and terminates.
I'm at a loss as to how to solve the problem. Any suggestions please?
-
Try casting your money fields to float and then round to 18
ex - round ((cast(1stmoneyfield as float) / (cast(2ndmoneyfield as float))),18)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|