title: Why precision is decreasing when multiply sum to other number
body: <p>I have encountered with following bug (or feature) in SQL Server.</p>
  
  <p>When I use <code>SUM (*column*)</code> where <code>column</code> has a <code>numeric(18, 8)</code> type and multiply it to any other number (integer or decimal) the result precision is reducing to <code>numeric(18, 6)</code>.</p>
  
  <p>Here is the example script to demonstrate.</p>
  
  <pre><code>CREATE TABLE #temp (Qnty numeric(18,8))
  
  INSERT INTO #temp (Qnty) VALUES (0.00000001)
  INSERT INTO #temp (Qnty) VALUES (0.00000002)
  INSERT INTO #temp (Qnty) VALUES (0.00000003)
  
  SELECT Qnty, 1*Qnty
  FROM #temp
  
  SELECT (-1)*SUM(Qnty), SUM(Qnty), -SUM(Qnty), SUM(Qnty) * CAST(2.234 as numeric(18,8))
  FROM #temp
  
  DROP TABLE #temp
  </code></pre>
  
  <p>The result of second SELECT query</p>
  
  <pre><code>0.000000    0.00000006  -0.00000006 0.000000
  </code></pre>
  
  <p>As you can see then I multiply SUM the result is 0.000000</p>
  
  <p>Could anyone explain the strange behavior?</p>
  
  <p>UPD. I executed this query in SQL Management Studio on 2000, 2005 and 2008 SQL Server.</p>