|
Posted by Erland Sommarskog on 10/01/36 11:41
(bartvanhemelen@gmail.com) writes:
> *
> ( @DiscountRate / 100 )
> )
>...
>
> The problem: instead of getting a low number (like 0.57 for instance),
> I get a 0. Right now I've "solved" this by replacing "( @DiscountRate /
> 100 )" with just "@DiscountRate" and then dividing by 100 in my asp
> code, but I'd really like to know what I'm doing wrong.
@DiscountRate was integer, correct?
You should have left out the parentheses above. This mandates SQL Server
to compute this expression before it gets mixed with the rest. But if
you divide two integers, you get integer division, which is not what you
want at all.
Assuming that what is before the * is money, leaving out the parenthesis,
transforms the division to money division.
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
[Back to original message]
|