Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: "Bob Barrows" Newsgroups: comp.databases.ms-sqlserver,microsoft.public.sqlserver.programming Subject: Re: SSE2008 money Type Date: Thu, 11 Oct 2012 06:40:28 -0400 Organization: A noiseless patient Spider Lines: 47 Message-ID: References: Injection-Date: Thu, 11 Oct 2012 10:40:32 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="bd099084a2caba1d0ebe690afacb9523"; logging-data="4053"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+aa8gZFZ3DtPq8RHeNoxWVTPTIOFZw/0Y=" X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-RFC2646: Format=Flowed; Original X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 Cancel-Lock: sha1:77cZnFCKwvzrwUuccBAkYG/dhF0= X-Priority: 3 X-MSMail-Priority: Normal Xref: csiph.com comp.databases.ms-sqlserver:1331 Gene Wirchenko wrote: > Dear SQLers: > > According to Microsoft > http://msdn.microsoft.com/en-us/library/aa258271%28v=sql.80%29.aspx > money has four decimal digits. Unfortunately, if I use print to check > things, I sometimes do not get the four digits displayed as in: > You're being caught by implicit conversions to varchar. > print 12.345; -- prints 12.345 Implicit conversion to varchar using the default style setting for float or real data (0), resulting in a maximum of 6 decimal places, using scientific notation when appropriate. > print convert(money,12.345); -- prints 12.35 Implicit conversion to varchar, using the default style setting for money/smallmoney (0 - no commas for thousands separators and 2 decimal places) > print 12.35-convert(money,12.345); -- prints 0.0050 Same as the first, with the wrinkle that arithmetic using money and real values results in a real value. > print convert(money,12.35)-convert(money,12.345); -- prints 0.01 Same as second - answer rounded to two places > print 12.345+convert(money,12.345)-12.345; -- prints 12.3450 Sane as third > > The precision is apparently there per the third statement, but > how do I force it? I have tried variations with the second statement, > but I have been unable to get it to output 12.345. How is it that the > third statement gives four decimal digits, but the second and fourth > do not? The fifth statement is just plain weird. > Look up the Style arguments for CONVERT() in BOL. This can all be avoided by using explicit conversions.