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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trigger Help

Status
Not open for further replies.

fpgiv

Programmer
Oct 1, 2003
91
US
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
 

It looks like the last part of the update is not needed:

join inserted i on project.id=i.id
 
Hi Mjia,
I just figured it out. I created a variable and stored the results of the query in there, which I then put in the update statement.
Thanks for your help though.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top