You are here: Re: Truncation errors in MS SQL « MsSQL Server « IT news, forums, messages
Re: Truncation errors in MS SQL

Posted by Erland Sommarskog on 06/16/05 16:16

Bruno Panetta (bpanetta@gmail.com) writes:
> The problem is that it doesn't matter which precision I choose, the
> results is always 29.99990.
> Even with decimal(38,30). Could this be a bug in my version of SQL
> (8.00.194)?
> Thanks

8.00.194 is indeed an old version, and you should upgrade to SP4. Get it
from http://www.microsoft.com/sql/downloads/2000/sp4.asp.

However, as I tried to explain, the operation you are trying cannot
succeed except than by chance. You *cannot* represent 3/35 as a decimal
number exactly, so you will get a rounding error. And once that rounding
error has been introduced, there is no controllable way that you can
get rid of it.

Did you try using decimal(28,10)? That worked for me in this example.
(But would may not work for other example.)


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация