I have a table that contains the test results of my school's students. I created an update trigger so that when the test results field is updated, the grades field will be updated too. After I successfully tested the trigger by manually adding individual records into the table, I found that some other procedures that used to work no longer do so! Basically these are update procedures that mass update the table. The error returned is:Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <=, >, >= or when the subquery is used as an expression.My trigger code looks something like this (it's very long so i cut it):ALTER TRIGGER dbo.MA_test_Results_doGradesON dbo.MA_test_ResultsAFTER UPDATEASIF UPDATE (Assmt_Marks)BEGINIF (SELECT Assmt_Marks FROM inserted) < 45BEGINUPDATE dbo.MA_test_Results SET Assmt_Grade = 'F' WHERE StudentId=(SELECT StudentId FROM inserted) AND Assmt_Id = (SELECT Assmt_Id FROM inserted)ENDEND
There are more codes but they are just reptitive for other grades. An example of those procedures that no longer works after this trigger is added:UPDATE dbo.MA_test_ResultsSET Assmt_Marks = NULLWHERE (Assmt_Grade = 'VR')
I know it's the trigger causing the problem cos when I removed it the procedures work again. Thanks for any insight into this.