title: Using SQL Server Arithmetic Operators on varchar Field
body: <p>I have a third party data source that has a <code>varchar(255)</code> column that contains only numbers. This column is the cost of an item. I would like to be able to multiply this column by a factor (2.3) to get a default selling price but I cannot apply arithmetic operators on the <code>varchar</code> column and the <code>CAST</code> function is producing an error when combined with the arithmetic operators.</p>
  
  <p>This statement produces the following sample results: </p>
  
  <pre><code>SELECT 
      AverageCost
  FROM 
      dbo.inventory
  </code></pre>
  
  <ul>
  <li>169</li>
  <li>32.5</li>
  <li>55.25</li>
  <li>8.42</li>
  <li>295</li>
  <li>0</li>
  <li>3.33333</li>
  </ul>
  
  <p>This satatement:</p>
  
  <pre><code>SELECT 
      AverageCost * 2.3 AS Price
  FROM 
      dbo.iteminventory
  </code></pre>
  
  <p>Produces this error </p>
  
  <blockquote>
    <p>Arithmetic overflow error converting data type numeric</p>
  </blockquote>
  
  <p>Writing the statement as follows to cast as a decimal produces no errors but adding the arithmetic operator into this statement has eluded me, my attempts have all resulted in errors.</p>
  
  <pre><code>SELECT 
      CAST(AverageCost AS Decimal(10, 2)) AS Price
  FROM 
      dbo.inventory
  </code></pre>
  
  <p>Thanks in advance for you help.</p>