Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. -- ================================================
  2. -- Template generated from Template Explorer using:
  3. -- Create Trigger (New Menu).SQL
  4. --
  5. -- Use the Specify Values for Template Parameters
  6. -- command (Ctrl-Shift-M) to fill in the parameter
  7. -- values below.
  8. --
  9. -- See additional Create Trigger templates for more
  10. -- examples of different Trigger statements.
  11. --
  12. -- This block of comments will not be included in
  13. -- the definition of the function.
  14. -- ================================================
  15. SET ANSI_NULLS ON
  16. GO
  17. SET QUOTED_IDENTIFIER ON
  18. GO
  19. -- =============================================
  20. -- Author: TSQL PROGRAMMER
  21. -- Create date:
  22. -- Description: Calcute studnet Grade
  23. -- =============================================
  24. CREATE TRIGGER dbo.ComputeGrade
  25. ON dbo.StudentMarks
  26. AFTER INSERT,UPDATE
  27. declare @markobtained int =(Select MarkObtained from inserted i )
  28. AS
  29. BEGIN
  30. -- SET NOCOUNT ON added to prevent extra result sets from
  31. -- interfering with SELECT statements.
  32. SET NOCOUNT ON;
  33.  
  34. if(@markobtained between 0 and 49)
  35. BEGIN
  36. UPDATE StudentMarks SET Grade='Fail'
  37. END
  38. ELSE IF (@markobtained between 50 and 64)
  39. BEGIN
  40. UPDATE StudentMarks SET Grade='Fair'
  41. END
  42. ELSE IF(@markobtained between 65 and 74)
  43. BEGIN
  44. UPDATE StudentMarks SET Grade ='Good'
  45. END
  46. ELSE IF(@markobtained between 75 and 84)
  47. BEGIN
  48. UPDATE StudentMarks SET Grade='Very Good'
  49. END
  50. ELSE IF(@markObtained between 85 and 100)
  51. BEGIN
  52. UPDATE StudentMarks SET Grade ='Excellent'
  53. END
  54. ELSE
  55.  
  56. PRINT'Invalid mark range'
  57.  
  58.  
  59. END
  60. GO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement