title: SQL Server decrementing inventory
body: <p>I am using SQL Server 2008. I have a table where orders with SKU are recorded, a table for inventory that has counts and a table where the relationship between the SKU sold and inventory items is recorded. </p>
  
  <p>In the end, I got the report like this</p>
  
  <pre><code> Inventory CurrentQuantity OpenedOrder
     SKU1        300             50
     SKU2        100             10
  </code></pre>
  
  <p>Each order will be processed individually. How can I have the database automatically update the inventory tablet after each order is processed?</p>
  
  <p>i.e</p>
  
  <p>If the order has 2 SKU1 in it got processed, the the inventory table will automatically show 298.</p>
  
  <p>Thanks</p>