title: Perform calculation for varchar data type column
body: <p>I have a inventory quantity column in database and its data type is varchar. When workers take out the product from store, the inventory quantity should be deducted. And I am having some problem when writing Sql statement:</p>
  
  <pre><code>public bool updateInventoryQty(string productID, int prodQty)
      {
          bool result = false;
          result = Conversion.intToBool(FoodBankDB.executeNonQuery(
              "UPDATE dbo.products SET inventoryQuantity = inventoryQuantity - prodQty WHERE id = '" + productID + "'"
              ));
  
          return result;
      }
  </code></pre>
  
  <p>I take in the amount taken out as parameter. Since the inventoryQuantity is varchar so I think it could not perform any calculation. So am I supposed to change it to:</p>
  
  <pre><code>"UPDATE dbo.products SET Convert(INT, inventoryQuantity) = inventoryQuantity - prodQty WHERE id = '" + productID + "'"
  </code></pre>
  
  <p>Am I doing in the correct way? Thanks in advance.</p>