Using trigger in one table and updating another table
CREATE TRIGGER dbo.updateTrigger
ON dbo.Education
AFTER UPDATE
AS
BEGIN
SET NOCOUNT ON;
IF NOT (UPDATE( HighestDegreeDoc) OR UPDATE (GPA) OR UPDATE (CreditHours))
RETURN
UPDATE dbo.School
set Uploaded =1
from dbo.School
JOIN inerted i ON i.Uploaded = School.Uploaded
END
GO
What is Wrong with this code. i am trying to up开发者_如何学JAVAdate field in School table , field uploaded when (HighestDegreeDoc , GPA, CrediHours) update in Education Table. NOTE Education Table has more than 15 field, (Uploaded Field in School table update only when these 3 field change)
Just a guess....
JOIN inerted i ON i.Uploaded = School.Uploaded
Should be...
JOIN inserted i ON i.SchoolId = School.SchoolId
Looks like Updated is some sort of flag that you are setting. You probably want to join on an ID column instead.
It's only a typo error : it's join inserted
;)
And I don't think your join condition is good.
Can you give us the ddl ?
精彩评论