Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

INSERT INTO Trigger

Status
Not open for further replies.

jacob94

Technical User
Dec 5, 2005
161
US
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top