﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2005 / SQL Server 2005 General Discussion  / Displaying Fewer Decimal Places / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Tue, 18 Jun 2013 16:18:46 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Displaying Fewer Decimal Places</title><link>http://www.sqlservercentral.com/Forums/Topic632398-149-1.aspx</link><description>Aha!  Decimal must be immune to a true round::Try this one!DECLARE @Gains AS floatSET @Gains=RAND()SELECT        @Gains        , ROUND(@Gains, 4) so maybe in your code you could cast to a float and round it.~BOT</description><pubDate>Thu, 08 Jan 2009 10:27:31 GMT</pubDate><dc:creator>SQLBOT</dc:creator></item><item><title>RE: Displaying Fewer Decimal Places</title><link>http://www.sqlservercentral.com/Forums/Topic632398-149-1.aspx</link><description>I looked into the ROUND() function as you guys suggested.  Maybe my implementation is off because while it rounds the value, it leaves on all the trailing zeros after the rounding takes place.  And since the goal is to make this reader friendly, the trailing zeros aren't helping.  Any ideas how to get rid of these trailing zeros?  DECLARE @Gains AS DECIMAL(18,8)SET @Gains=RAND()SELECT	@Gains	, ROUND(@Gains, 4) Gave me:  0.67144808	0.67140000</description><pubDate>Thu, 08 Jan 2009 09:24:21 GMT</pubDate><dc:creator>bkmooney</dc:creator></item><item><title>RE: Displaying Fewer Decimal Places</title><link>http://www.sqlservercentral.com/Forums/Topic632398-149-1.aspx</link><description>Oh yeah, forgot about ROUND()</description><pubDate>Thu, 08 Jan 2009 08:46:41 GMT</pubDate><dc:creator>  Jack Corbett</dc:creator></item><item><title>RE: Displaying Fewer Decimal Places</title><link>http://www.sqlservercentral.com/Forums/Topic632398-149-1.aspx</link><description>I think using cast or convert is your only option if you are just using SSMS.  It is using whatever the data type is for your column, so you could reset that if you don't need that precision, unless you are using float.</description><pubDate>Thu, 08 Jan 2009 08:46:07 GMT</pubDate><dc:creator>  Jack Corbett</dc:creator></item><item><title>RE: Displaying Fewer Decimal Places</title><link>http://www.sqlservercentral.com/Forums/Topic632398-149-1.aspx</link><description>investigate the ROUND() function.~BOT</description><pubDate>Thu, 08 Jan 2009 08:45:52 GMT</pubDate><dc:creator>SQLBOT</dc:creator></item><item><title>RE: Displaying Fewer Decimal Places</title><link>http://www.sqlservercentral.com/Forums/Topic632398-149-1.aspx</link><description>Oh yeah, I am just running this query in the MS SQL Server Mgmt Studio if that makes a difference.</description><pubDate>Thu, 08 Jan 2009 08:42:11 GMT</pubDate><dc:creator>bkmooney</dc:creator></item><item><title>RE: Displaying Fewer Decimal Places</title><link>http://www.sqlservercentral.com/Forums/Topic632398-149-1.aspx</link><description>Here is a simplified version of the query.  The actual query contains about a dozen items in the select statement similar to this calculation.  SELECT      Param1      , Param2      , Param3      , EXP(SUM(CASE WHEN(Date BETWEEN '2007-01-01' AND '2008-01-01') THEN (LOG(1+Gains)) ELSE 0 END))-1 as CY2007PercGainFROM myTableGROUP BY      Param1      , Param2      , Param3Param1, Param2, Param3, and Gains are all type DECIMAL(18,8),  and Date is type DATETIME</description><pubDate>Thu, 08 Jan 2009 08:41:36 GMT</pubDate><dc:creator>bkmooney</dc:creator></item><item><title>RE: Displaying Fewer Decimal Places</title><link>http://www.sqlservercentral.com/Forums/Topic632398-149-1.aspx</link><description>What are you using to display the results?  What are the datatypes of the columns in the calculations?  Can you post the query?</description><pubDate>Thu, 08 Jan 2009 08:31:28 GMT</pubDate><dc:creator>  Jack Corbett</dc:creator></item><item><title>Displaying Fewer Decimal Places</title><link>http://www.sqlservercentral.com/Forums/Topic632398-149-1.aspx</link><description>I have a query that is compiling hundreds of rows of data to determine performance statistics.  While the calculations are correct, they are displaying far more decimal places than is necessary (15 places).  Is there a way to limit all display output to a fixed number of decimals (say 4 or 5) with one command?  Or for each column in my select list would I have to use the CAST() function?    </description><pubDate>Thu, 08 Jan 2009 07:47:31 GMT</pubDate><dc:creator>bkmooney</dc:creator></item></channel></rss>