Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ================================================
- -- 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement