You are here: Re: Display Money Type using + and - « MsSQL Server « IT news, forums, messages
Re: Display Money Type using + and -

Posted by Mike Reigler on 10/01/49 11:28

Nevermind. After some more digging I realized what was happening when MONEY
/ MONEY. Thanks.

Mike Reigler

"Mike Reigler" <mreigler@melange-inc.com> wrote in message
news:11k800hit25ci21@corp.supernews.com...
> Why is this the case? From the definition of MONEY in BOL I would expect
> the same result.
>
> Mike Reigler
>
> "David Portas" <REMOVE_BEFORE_REPLYING_dportas@acm.org> wrote in message
> news:1128520608.921999.41930@z14g2000cwz.googlegroups.com...
>> No offence. I was trying to help but first I needed more information.
>> There could have been more than one reason why you'd want to do this -
>> for example you could have had a requirement to integrate the data with
>> an external application.
>>
>> The reason I ask about MONEY in particular is that the problems with
>> using that datatype in calculations may sometimes be overlooked. Take a
>> look at the following example. Be aware of the rounding issue when you
>> develop calculations against the data and think carefully about the
>> implications before you use MONEY.
>>
>> DECLA RE
>> @mon1 MONEY,
>> @mon2 MONEY,
>> @mon3 MONEY,
>> @mon4 MONEY,
>> @num1 DECIMAL(19,4),
>> @num2 DECIMAL(19,4),
>> @num3 DECIMAL(19,4),
>> @num4 DECIMAL(19,4)
>>
>> SELECT
>> @mon1 = 100, @mon2 = 339, @mon3 = 10000,
>> @num1 = 100, @num2 = 339, @num3 = 10000
>>
>> SET @mon4 = @mon1/@mon2*@mon3
>> SET @num4 = @num1/@num2*@num3
>>
>> SELECT @mon4 AS money_result,
>> @num4 AS numeric_result
>>
>> Result:
>>
>> money_result numeric_result
>> --------------------- ---------------------
>> 2949.0000 2949.8525
>>
>> (1 row(s) affected)
>>
>> --
>> David Portas
>> SQL Server MVP
>> --
>>
>
>

 

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

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