In a inventory managment system can be as complex or as simple as you want and it depends on your needs. A simple rule of thumb to use though is to not make your data dependent on 1 updated record, it's a potential for disastor.Keep all the inventory transactions in a seperate table to increase decrease the value, then update the total.So in it's simplest form.IF OBJECT_ID('tempDb..#Items') IS NOT NULL DROP TABLE #ItemsSelect 1 as ItemID,'My Item 1' as ItemDesc, 3 as QtyOnHand Into #Itemsunion allSelect 2,'My Item 2', 10 as QtyOnHand union allSelect 3,'My Item 3', 78 as QtyOnHandIF OBJECT_ID('tempDb..#InventoryAdjustments') IS NOT NULL DROP TABLE #InventoryAdjustmentsSelect 1 as ItemID,'My Item 1' as ItemDesc, 3 as Adjustmentsinto #InventoryAdjustmentsunion allSelect 2,'My Item 2', 10 union allSelect 3,'My Item 3', 78 Union allSelect 1 as ItemID,'My Item 1' as ItemDesc, -3 as Adjustments union allSelect 2,'My Item 2', -1 union allSelect 3,'My Item 3', -20 Union allSelect 1 as ItemID,'My Item 1' as ItemDesc, 7 as Adjustments union allSelect 2,'My Item 2', 10 union allSelect 3,'My Item 3', 99 Update aset QtyOnHand = b.Adjustmentsfrom#Items aInner Join( Select ItemID,sum(Adjustments) as Adjustments from #InventoryAdjustments aa group by ItemID) bon a.ItemID = b.ItemIDselect * from #ItemsThis way you are tracking all the modifications and the QTY ON HAND is far less prone to a error.
Success is 10% Intelligence, 70% Determination, and 22% Stupidity.\_/ _/ _/\_/ _/\_/ _/ _/- 881