USE Northwind CREATE TRIGGER OrdDet_Insert ON [Order Details] FOR INSERT AS UPDATE P SET UnitsInStock = P.UnitsInStock ? I.Quantity FROM Products AS P INNER JOIN Inserted AS I ON P.ProductID = I.ProductID
USE Northwind CREATE TRIGGER Category_Delete ON Categories FOR DELETE AS UPDATE P SET Discontinued = 1 FROM Products AS P INNER JOIN deleted AS d ON P.CategoryID = d.CategoryID
USE Northwind GO CREATE TRIGGER Employee_Update ON Employees FOR UPDATE AS IF UPDATE (EmployeeID) BEGIN RAISERROR (’Transaction cannot be processed. ***** Employee ID number cannot be modified.’, 10, 1) ROLLBACK TRANSACTION END