I am looking to add the following logic to the trigger below but I could use a little help. I have a table where I am assigning criteria that I want to select on in the below trigger to reduce the amount of records the trigger returns. I am not sure of the best and most efficient way to do this. Is it with some kind of IF statement before the BEGIN or is it simply adding the third table to the select statement. Please advise.
The criteria table has the following fields.
L1, L2
I would need to join them in the select statement below somehow I guess. What is the best way to do this? Can I evaluate each record during the INSERT INTO statement and only append IF L1 and L2 match the criteria table? L1 and L2 are also in the table that the trigger is assigned too.
FOR INSERT
AS
BEGIN
INSERT INTO dbo.TempCC
(ID, CID)
Select i.ID, p.CID
From inserted i
join TempP p on i.CID = p.CID
END
The criteria table has the following fields.
L1, L2
I would need to join them in the select statement below somehow I guess. What is the best way to do this? Can I evaluate each record during the INSERT INTO statement and only append IF L1 and L2 match the criteria table? L1 and L2 are also in the table that the trigger is assigned too.
FOR INSERT
AS
BEGIN
INSERT INTO dbo.TempCC
(ID, CID)
Select i.ID, p.CID
From inserted i
join TempP p on i.CID = p.CID
END