title: SQL is rounding my decimal on cast
body: <p>I'm using SQL Server 2005. The datatype is <code>varchar</code>.  I'm trying to convert numbers like</p>
  
  <pre><code>1250000
  </code></pre>
  
  <p>to </p>
  
  <pre><code>1.25
  </code></pre>
  
  <p>within the SQL query and drop the trailing zeroes. I have tried a number of things with no success - have run into 'trim is not a function', etc.  </p>
  
  <p>Here's what I currently have, in each iteration that I have attempted.</p>
  
  <pre><code>select top 30 
      var1, var2, var3, var4, 
      CONVERT(DECIMAL(6,2), (var5 / 1000000)) as 'Number' 
  from 
      databasetable 
  where 
      var1 = x 
  
  select top 30 
      var1, var2, var3, var4, 
      cast((var5 / 1000000) as decimal(6,2)) as 'Number' 
  from 
      databasetable 
  where 
      var1 = x 
  </code></pre>
  
  <p>Both queries above are rounding to the nearest million, i.e. 1250000 becomes 1.00, etc. Any ideas would be much appreciated. Changing decimal to numeric did not help either.</p>