title: Divide by zero error encountered in SQL Server 2014
body: <p>In this specific part of a query I'm trying to create, I'm getting a "divide by zero" error. I believe this is because I'm trying to divide <code>ARTran.Qty</code> by a null. I'm unsure how I can work around this... (I'm using <code>Cast</code> as in the next part of the query I'm trying to using this number as a decimal</p>
  
  <pre><code>(CASE WHEN ([ARTran].[UOM] LIKE 'EACH') 
           THEN CAST([ARTran].[Qty] AS VARCHAR(30)) 
        ELSE CAST((ARTran.Qty / InventoryItem.UsrLength) AS VARCHAR(30))
   END)
  </code></pre>
  
  <p>Can someone point me in the right direction? I've looked at a few other threads on this, but I'm still not sure how to solve this.</p>