Question: Reset the Chapter 7 . Students table and Chapter 7 . StudentAudit table back to no data. - - GO CREATE OR ALTER TRIGGER Chapter
Reset the ChapterStudents table and ChapterStudentAudit table back to no data.
GO
CREATE OR ALTER TRIGGER ChaptertrgStudentsInsertCheckGPA
ON ChapterStudents
INSTEAD OF INSERT
AS
SET NOCOUNT ON;
DECLARE @studentId AS INT;
DECLARE @newGpa AS DECIMAL;
SELECT @newGpa StudentGpa FROM INSERTED;
BEGIN
IF@newGpa OR @newGpa
BEGIN
RAISERRORGPA must be between and ;
ROLLBACK;
END
ELSE
BEGIN
INSERT INTO ChapterStudents
StudentName StudentGpa
SELECT StudentName, StudentGpa
FROM INSERTED;
SET @studentId SCOPEIDENTITY;
INSERT INTO ChapterStudentsAudit
StudentId StudentName, StudentGpa, AuditAction
SELECT @studentId, studentName, studentGpa,
'Insert a new student'
FROM inserted;
PRINTRecord inserted';
END;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
