That's not a bug, that's a perfectly predictable result based on the
datatype (all you have to know is whether the rule is to round or truncate
excess decimals), using the money datatype in this way may well introduce
bugs into your app but that's not the same as saying money is bugged.
Consider:-
declare @m money
set @m = 12.39
SET NOCOUNT ON
SELECT @m, convert(char(2), SQL_VARIANT_PROPERTY (@m, 'scale')),
convert(char(20), SQL_VARIANT_PROPERTY (@m, 'basetype'))
SELECT (@m/1000), convert(char(2), SQL_VARIANT_PROPERTY ((@m/1000),
'scale')), convert(char(20), SQL_VARIANT_PROPERTY (@m, 'basetype'))
SELECT (@m/1000)*1000, convert(char(2), SQL_VARIANT_PROPERTY
((@m/1000)*1000, 'scale')), convert(char(20), SQL_VARIANT_PROPERTY (@m,
'basetype'))
SET NOCOUNT OFF
Output:-
--------------------- ---- --------------------
12.3900 4 money
--------------------- ---- --------------------
..0123 4 money
--------------------- ---- --------------------
12.3000 4 money
Compare with:-
declare @d decimal(19,4)
set @d = 12.39
SET NOCOUNT ON
SELECT @d, convert(char(2), SQL_VARIANT_PROPERTY (@d, 'scale')),
convert(char(20), SQL_VARIANT_PROPERTY (@d, 'basetype'))
SELECT (@d/1000), convert(char(2), SQL_VARIANT_PROPERTY ((@d/1000),
'scale')), convert(char(20), SQL_VARIANT_PROPERTY (@d, 'basetype'))
SELECT (@d/1000)*1000, convert(char(2), SQL_VARIANT_PROPERTY
((@d/1000)*1000, 'scale')), convert(char(20), SQL_VARIANT_PROPERTY (@d,
'basetype'))
SET NOCOUNT OFF
Output:-
--------------------- ---- --------------------
12.3900 4 decimal
-------------------------- ---- --------------------
..012390000 9 decimal
------------------------------- ---- --------------------
12.390000000 9 decimal
and you can see the trick that the decimal datatype is pulling in order to
accomodate the extra decimal places, as money is restricted to 4 decimals it
cannot pull this trick.
--
Terry Kreft
"Jamie Collins" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> Rick Brandt wrote:
> > If I am in a position to choose I always use the money type in SQL
Server for
> > stuff that needs decimals if I want to manipulate them from an Access
interface.
>
> <surprised> *Any* stuff that need decimals? Are you are aware of the
> MONEY bug?:
>
>
http://groups.google.com/group/micro...861dc4d5e0705?
>
> "If you will be multiplying and dividing [MONEY data] (especially in
> the other order),
> I'd recommend decimal(19,4), otherwise you might see serious
> inaccuracies. Here's a simple example of where using money creates a
> quick error of almost 1%..."
>
> Jamie.
>
> --
>