title: Arithmetic overflow error converting int to data type numeric
body: <p>How can I fix this error in T-SQL?  The following line executes successfully:</p>
  
  <pre><code>SET @dPERCENT_QC_COMPLETED = CASE WHEN @NUM_QC_RECEIVED = 0 
                                 THEN 0 
                                 ELSE @NUM_QC_COMPLETED / @NUM_QC_RECEIVED 
                               END
  </code></pre>
  
  <p>But this line fails with error code below:</p>
  
  <pre><code>SET @dPERCENT_QC_COMPLETED = CASE WHEN @NUM_QC_RECEIVED = 0
                                 THEN 0
                                 ELSE (100 * @NUM_QC_COMPLETED / @NUM_QC_RECEIVED)
                               END
  </code></pre>
  
  <p>Msg 8115, Level 16, State 8, Line 73
  Arithmetic overflow error converting int to data type numeric.</p>
  
  <p>@dPERCENT_QC_COMPLETED is a decimal(2).  The other variables are integers.  Problem I think is that currently these other integer values = 1, so this expression evaluates to 1.</p>