I have a number of tables with cascading relational constraints. When I update the parent table it cascades down through the whole relational tree perfectly however there is a field that is not part of the relationship that needs to be updated in the child tables ONLY if the related field changed. I have attempted this using the following code in a trigger in the parent table. There are a total of 11 child tables being updated with similar code in the complete trigger. The problem is that when enabled it's pretty obvious the trigger is not executing efficiently. I believe there are good indexes for each of the child tables but I can't seem to get decent performance out of the trigger. Can anyone point me to the error of my ways?
Code:
UPDATE [SOLINES]
SET [COMPANY] = I.[COMPANY]
,[Edited_View] = I.[Edited_View]
FROM [SOLINES] AS S
JOIN Inserted AS I
ON S.[Seq_No] = I.[Seq_No]
JOIN DELETED AS D
ON I.Seq_NO = D.Seq_No
WHERE S.[SEQ_NO] = I.[Seq_No] -- Unique indexed key
AND D.[COMPANY] <> I.[COMPANY] -- Company name was changed....