Section 1
True/False Questions
(10 Marks, 1 mark each)
1. A stored procedure in SQL Server can accept input parameters to make it reusable.
2. A trigger can be fired manually by executing it with an EXEC statement.
3. You can use a WHILE loop inside a stored procedure to repeatedly execute
statements.
4. The TRY...CATCH block in SQL Server allows you to handle errors in procedures or
triggers.
5. BEGIN TRANSACTION must always be followed by a COMMIT or ROLLBACK to
complete the transaction.
6. A procedure with parameters cannot contain variables.
7. An AFTER trigger executes before the DML statement modifies the table.
8. IF...ELSE constructs in a procedure allow conditional execution of SQL statements.
9. ROLLBACK inside a transaction will undo all changes made since the last COMMIT.
10. A stored procedure can return multiple result sets from SELECT statements.
Section 2 - Practical (90 M arks)
Use SQL Server Management Studio (SSMS) on your computer to complete this section .
Instructions:
Copy and paste your final code into the designated space for each question on eLearning.
Ensure you also keep a copy of your work in Notepad as a backup in case of any technical issues.
Use the scenario and table provided below to answer all the questions.
Scenario:
A Classroom Management System helps teachers ensure lessons run smoothly and track
students' behavior. You are required to use stored procedures in SQL Server to manage,
analyze, and report data for this system.
CREATE TABLE STUDENT BEHAVIOR (
Student ID INT PRIMARY KEY,
FirstName VARCHAR(S0),
LastNarne VARCHAR(S0),
GradeLevel VARCHAR(l0),
BehaviorStatus VARCHAR(20),
DateReported DATE
);
2