Hi, I am trying to create a trigger that updates a table field with the sum of the results of another query. I want to populate the sqa field of projects with the sum +1 of all projects that have a test_fk that belong to a specific phase. Here is my trigger, but I keep getting incorrect syntax. Thanks!
CREATE TRIGGER addsqa
ON project
FOR INSERT
AS
BEGIN
update project set sqa= (select count(*) as temp from project, inserted where project.id=inserted.id and test_fk in
(select test_id from testing.dbo.tests where test_phase in (select phase_id from testing.dbo.phases)))
join inserted i on project.id=i.id
END
CREATE TRIGGER addsqa
ON project
FOR INSERT
AS
BEGIN
update project set sqa= (select count(*) as temp from project, inserted where project.id=inserted.id and test_fk in
(select test_id from testing.dbo.tests where test_phase in (select phase_id from testing.dbo.phases)))
join inserted i on project.id=i.id
END