My trigger is meant to calcalute the grade of a student base on the column value for every insert.But if a column value for the column is modified it the corresponding Grade should change. Currently i having error:"
Invalid object name StudentMarks for each code section.
I did some search to the cause of the error but still can find one. Please advise
-- ================================================ -- Template generated from Template Explorer using: -- Create Trigger (New Menu).SQL -- -- Use the Specify Values for Template Parameters -- command (Ctrl-Shift-M) to fill in the parameter -- values below. -- -- See additional Create Trigger templates for more -- examples of different Trigger statements. -- -- This block of comments will not be included in -- the definition of the function. -- ================================================ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: TSQL PROGRAMMER -- Create date: -- Description: Calcute studnet Grade -- ============================================= CREATE TRIGGER dbo.ComputeGrade ON dbo.StudentMarks AFTER INSERT,UPDATE declare @markobtained int =(Select MarkObtained from inserted i ) AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; if(@markobtained between 0 and 49) BEGIN UPDATE StudentMarks SET Grade='Fail' END ELSE IF (@markobtained between 50 and 64) BEGIN UPDATE StudentMarks SET Grade='Fair' END ELSE IF(@markobtained between 65 and 74) BEGIN UPDATE StudentMarks SET Grade ='Good' END ELSE IF(@markobtained between 75 and 84) BEGIN UPDATE StudentMarks SET Grade='Very Good' END ELSE IF(@markObtained between 85 and 100) BEGIN UPDATE StudentMarks SET Grade ='Excellent' END ELSE PRINT'Invalid mark range' END GO