Using the "Northwind" sample:
I would like to create an insert trigger on the OrderDetails table so that every time an OrderDetail is inserted, it gets the current value of the UnitCost as defined in the Products table.
It should be something like this, but I have trouble to get it right. Can you help ?
CREATE TRIGGER Trigger1 ON OrderDetails as od FOR INSERT AS -- save unit cost od.unitCost = (select UnitCost from Products as p WHERE p.ProductId = i.ProductId )
I am using SQL Server 2008. Thanks !