1. Learn
  2. /
  3. Courses
  4. /
  5. Building and Optimizing Triggers in SQL Server

Exercise

Practicing with AFTER triggers

Fresh Fruit Delivery company is happy with your services, and they've decided to keep working with you.

You have been given the task to create new triggers on some tables, with the following requirements:

  • Keep track of canceled orders (rows deleted from the Orders table). Their details will be kept in the table CanceledOrders upon removal.

  • Keep track of discount changes in the table Discounts. Both the old and the new values will be copied to the DiscountsHistory table.

  • Send an email to the Sales team via the SendEmailtoSales stored procedure when a new order is placed.

Instructions 1/3

undefined XP
  • 1

    Create a new trigger on the Orders table to keep track of any canceled orders.

  • 2

    Create a new trigger on the Discounts table to keep track of discount value changes.

  • 3

    Create the trigger NewOrderAlert to notify the Sales team when new orders are placed.