From the course: SQL Server Database Triggers
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Counting shipments received - SQL Server Tutorial
From the course: SQL Server Database Triggers
Counting shipments received
- The first trigger that I want to write for the inventory management system is to insert a row into the inventory audit table. Anytime a change is made to the quantity of products on hand. To get started let's just review the starting state of both of the tables that we'll be working with. So I'll select everything from products and select everything from inventory audit. In the products table we currently have four products and they all have a quantity on hand of zero. There aren't any rows inside of the inventory audit table yet. So what I want to happen is anytime we update the quantity inside of the products table, we're going to add in a new row into the audit. That gives me the product that was changed. The time the changed happened, the old quantity and the new quantity that's being inserted into the products table. In order to do that we're going to create a trigger and that starts on line number 12. So we're…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.