Start a new topic

Displaying result in scientific notation

[This topic is migrated from our old forums. The original author name has been removed]

Hi, Why would the following query return the result in scientific notation? This only happens when the value is 0. Other values return the result as expected. declare @x DECIMAL(12,9), @y DECIMAL(12,9) select @x = 0, @y = 1 select @x as x, @y as y x y----- 0E-9 1.000000000 ----- Dbvis 9.03. Database SQL server 8 OR sybase 12.5 ----- If I use the MS Query analyzer tool the results are: x y ----- .000000000 1.000000000 Thanks, Gary

[This reply is migrated from our old forums.]

Re: Displaying result in scientific notation
Hi Gary, The default number format for Decimal is "Unformatted" and that results in scientific notation for 0 (Java rule, don't ask me why). If you want it to be presented as "0", set the Decimal Number Format to "####.##" in Tool Properties, Data Formats. Or as "0.0", set it to "###0.0#" (the field can be edited if none of the predefined patterns are suitable). All numeric pattern symbols that you can use are described here: http://docs.oracle.com/javase/6/docs/api/java/text/DecimalFormat.html Best Regards, Hans
[This reply is migrated from our old forums. The original author name has been removed]

Re: Displaying result in scientific notation
Thanks Hans, That fixed it. I chose #,###.#################### as the decimal number format. Slightly modifying the example in the original post as: declare @x DECIMAL(18,9), @y DECIMAL(18,9) select @x = 0, @y = 123456789.123456789 select @x as x, @y as y produces result: x y - --------------------- 0 123,456,789.123456789 Gary