Subject | Overflow on multiplying decimals |
---|---|
Author | Maya Opperman |
Post date | 2010-07-28T11:06:38Z |
Hi,
Is there an way of preventing an overflow error no the following stored procedure calculation:
OExtendedPrice = cast((IPrice * IQty) as decimal(18,2));
IQTY decimal(18,3) = 100.000
IPRICE decimal(18,2) = 4,039,250,052,178.13
OEXTENDEDPRICE decimal(18,2) will be 403,925,005,217,813.00 (still within 18 significant digits, 17 actually)
I tried
OExtendedPrice = cast((IPrice * IQty) as decimal(18,2));
but it still gives an error.
I know it gives an error because the result is 403,925,005,217,813.00000 before being passed to 403,925,005,217,813.00, but is there any way I can tell it to drop the last 3 decimal places up front?
Thanks
Maya
[Non-text portions of this message have been removed]
Is there an way of preventing an overflow error no the following stored procedure calculation:
OExtendedPrice = cast((IPrice * IQty) as decimal(18,2));
IQTY decimal(18,3) = 100.000
IPRICE decimal(18,2) = 4,039,250,052,178.13
OEXTENDEDPRICE decimal(18,2) will be 403,925,005,217,813.00 (still within 18 significant digits, 17 actually)
I tried
OExtendedPrice = cast((IPrice * IQty) as decimal(18,2));
but it still gives an error.
I know it gives an error because the result is 403,925,005,217,813.00000 before being passed to 403,925,005,217,813.00, but is there any way I can tell it to drop the last 3 decimal places up front?
Thanks
Maya
[Non-text portions of this message have been removed]