From the course: Complete Guide to Advanced SQL Server

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Reorder items when low

Reorder items when low

The third and final trigger that I want to add for the inventory management system is to increase the number of products that we have available on hand to sell whenever the warehouse receives a new shipment of inventory from our suppliers. Let's take a look at the tables we'll be working with in this case. It's going to be the Products table and the WarehouseReceiving table. So right now, we have five different products, and there's the quantity on hand for each one. And we don't have any rows inside of the WarehouseReceiving table. So when I do add a row to the WarehouseReceiving table, I want to automatically add the quantity received to the appropriate products total. To do that, we'll create a trigger starting on line number 11 here in the script. So I'm going to create a trigger called RestockProducts on the WarehouseReceiving table. This is going to be an AFTER INSERT trigger. So anytime the WarehouseReceiving table receives an insert, it's going to update the Products table…

Contents