Being refreshing my sql knowledge. So for triggers.SQL example.USE AdventureWorks2012;GOIF OBJECT_ID ('Purchasing.LowCredit','TR') IS NOT NULL DROP TRIGGER Purchasing.LowCredit;GO-- This trigger prevents a row from being inserted in the Purchasing.PurchaseOrderHeader table-- when the credit rating of the specified vendor is set to 5 (below average).CREATE TRIGGER Purchasing.LowCredit ON Purchasing.PurchaseOrderHeaderAFTER INSERTASIF EXISTS (SELECT * FROM Purchasing.PurchaseOrderHeader p JOIN inserted AS i ON p.PurchaseOrderID = i.PurchaseOrderID JOIN Purchasing.Vendor AS v ON v.BusinessEntityID = p.VendorID WHERE v.CreditRating = 5 )BEGINRAISERROR ('A vendor''s credit rating is too low to accept newpurchase orders.', 16, 1);ROLLBACK TRANSACTION;RETURN END;GO-- This statement attempts to insert a row into the PurchaseOrderHeader table-- for a vendor that has a below average credit rating.-- The AFTER INSERT trigger is fired and the INSERT transaction is rolled back.INSERT INTO Purchasing.PurchaseOrderHeader (RevisionNumber, Status, EmployeeID,VendorID, ShipMethodID, OrderDate, ShipDate, SubTotal, TaxAmt, Freight)VALUES (2,3,261 ,1652 ,4 ,GETDATE(),GETDATE(),44594.55 ,3567.564 ,1114.8638 );GO
JOIN inserted AS i ? This is not to be found in the database i have (latest AdventureWorks2012).Or is it a trigger based statement?So the trigger will check for CreditRating = 5 on all rows(?).Can i determine the specific row(s) that is inserted instead?Thanks.