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 tableCanceledOrders
upon removal.Keep track of discount changes in the table
Discounts
. Both the old and the new values will be copied to theDiscountsHistory
table.Send an email to the Sales team via the
SendEmailtoSales
stored procedure when a new order is placed.
Este ejercicio forma parte del curso
Building and Optimizing Triggers in SQL Server
Ejercicio interactivo práctico
Prueba este ejercicio completando el código de muestra.
-- Create a new trigger for canceled orders
CREATE TRIGGER KeepCanceledOrders
ON ___
AFTER ___
AS
INSERT INTO ___
SELECT * FROM deleted;