Create TRIGGER trg_Student_Monitoring ON Categories AFTER UPDATE AS
IF (select COUNT(name) from students s, deleted d where s.studentId = d.studentID and s.categoryId = 4 )>=1
Begin
INSERT INTO Students_Temp(StudentID, StudentNAME, StudentCategory)
SELECT I.StudentID, I.StudentNAME, I.StudentCategory FROM INSERTED I
End
IF (select COUNT(name) from students s, deleted d where s.studentId = d.studentID and s.categoryId = 4 )>=1
Begin
INSERT INTO Students_Temp(StudentID, StudentNAME, StudentCategory)
SELECT I.StudentID, I.StudentNAME, I.StudentCategory FROM INSERTED I
End