I want to create a trigger on a table in my DB, called "Assoc_Persons". This table allows me to link persons from the "Persons" Table to the "Incidents" Table. Each entry in the Incident Table can have multiple persons attached to it and the purpose of the Assoc_Persons table is to capture data relative to the time the record was created (snap-shot) such as their Work Unit, their title etc. So what I want to do is that every time there is a Insert, Update or Delete in the Assoc_Persons I want to search the Assoc_Persons table for other Persons attached to this incident, append them togehter and and then copy the data into another table Called Incident_Persons. In between the names I want to insert a "vbNewLine" so that when I display this data in a RIchtextbox they look like this:

Mr. John Smith
Ms. Francine Thompson
Dr. Larry Wilder

A simplified schema of the tables are as follows:

Persons - PERNUM, FNAM, LNAM, UNIT, TITLE
Assoc_Person - APERNUM, PERNUM, INCNUM, TITLE, UNIT
Incidents - INCNUM, DATE, Incident_Number
Incident_Persons - INCNUM, PERSON
So I decided to create a trigger and here is what I have so far:

VB Code:
  1. CREATE TRIGGER trig_update_Person
  2. ON ASSOC_Persons
  3. FOR UPDATE
  4. AS
  5.  
  6. DECLARE @INCNUM INT
  7. DECLARE @TITLE VARCHAR(50)
  8. DECLARE @FNAM VARCHAR(50)
  9. DECLARE @LNAM VARCHAR(50)
  10. DECLARE @PERNUM INT
  11. DECLARE @PERSON VARCHAR(1000)
  12.  
  13. IF NOT UPDATE(LNam) AND NOT UPDATE(FNam)
  14. BEGIN
  15. RETURN
  16. END
  17.  
  18. SELECT @INCNUM = (SELECT INCNUM FROM Updated)
  19. SELECT @INCNUM = (SELECT INCNUM FROM Inserted)
  20.  
  21. SELECT * FROM ASSOC_Persons WHERE INCNUM = @INCNUM
  22.  
  23. SELECT @PERNUM=PERNUM,@TITLE=PER.TITLE,@LNAM=PER.LNAM,@FNAM=PER.FNAM
  24. FROM Persons AS PER INNER JOIN ASSOC_Persons AS APER ON
  25. PER.INCNUM = APER.INCNUM
  26. WHERE APER.INCNUM = @INCNUM
  27.  
  28. Do While Not EOF
  29. BEGIN
  30.    @PERSON = @PERSON + @TITLE + ' ' + @FNAM + ' ' + @LNAM
  31. END
  32.  
  33. INSERT INCIDENT_PERSONS VALUES(@INCNUM,@PERSON)

But I am getting stuck on how do I loop through the Assoc_Persons Table in order to get the records.

Thanks