1

It seems Money has a fixed precision and always have 4 decimals. This causes me problems cause lets say I have a table of items to sell, like below

create table #example (
   id int,
   name varchar(50),
   price money
)

If the money column in #example is the price before VAT and VAT value is 8%, 4 decimals might not be enough. In below example I'm using an item price of 11usd (before vat)

insert into #example (id, name, price) values (1, 'asd', 11/1.08)

A select from #example now gives:

id  name price
1   asd 10,1852

If I want to use this price to add the vat value I get the wrong value:

10.1852*1,08 = 11,000016

This leaves a wrong margin of 0,000016USD. Obviously I'm using it wrong. Anyone have any input on where I'm wrong on this?

Edit: I wouldn't say the attached question has my answer. I'm already certain to use money and I just need help on calculating the values back.

Dave
  • 253
  • 6
  • 14
  • I ran that query in SQL2012 and got the correct answer - 10.185 both using "(11/1.08)" and using simply "11/1.08", so you might check the version and see if there's an issue related to the versioning. – Brian Jan 21 '15 at 10:15
  • I'm running this on 2012 aswell, but I don't get why 10.185 is right? 10.185*1,08 is 10,9998. I'm prob missing something, I just don't know what :) – Dave Jan 21 '15 at 10:31
  • This what my code: insert into _testmoney values (2,'dog',11/1.08) select * from _testmoney – Brian Jan 21 '15 at 11:58

0 Answers0