0
0
Testing Fundamentalstesting~20 mins

Stored procedure testing in Testing Fundamentals - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Stored Procedure Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
Output of a simple stored procedure call
Consider the following stored procedure that returns the total count of employees in a company.

What will be the output of calling EXEC GetEmployeeCount; if the Employees table has 150 rows?
Testing Fundamentals
CREATE PROCEDURE GetEmployeeCount AS BEGIN SELECT COUNT(*) AS TotalEmployees FROM Employees; END;
ATotalEmployees = 0
BNo output
CSyntax error
DTotalEmployees = 150
Attempts:
2 left
💡 Hint
The procedure counts all rows in the Employees table.
📝 Syntax
intermediate
2:00remaining
Identify the syntax error in stored procedure
Which option contains a syntax error when creating a stored procedure that inserts a new employee?
Testing Fundamentals
CREATE PROCEDURE AddEmployee @Name VARCHAR(50), @Age INT AS BEGIN INSERT INTO Employees (Name, Age) VALUES (@Name, @Age); END;
ACREATE PROCEDURE AddEmployee @Name VARCHAR(50), @Age INT AS BEGIN INSERT INTO Employees (Name, Age) VALUES (@Name, @Age); END;
BCREATE PROCEDURE AddEmployee @Name VARCHAR(50), @Age INT BEGIN INSERT INTO Employees (Name, Age) VALUES (@Name, @Age); END;
CCREATE PROCEDURE AddEmployee @Name VARCHAR(50), @Age INT AS INSERT INTO Employees (Name, Age) VALUES (@Name, @Age);
DCREATE PROCEDURE AddEmployee (@Name VARCHAR(50), @Age INT) AS BEGIN INSERT INTO Employees (Name, Age) VALUES (@Name, @Age); END;
Attempts:
2 left
💡 Hint
Check for missing keywords or misplaced syntax in procedure declaration.
optimization
advanced
2:00remaining
Optimizing a stored procedure for performance
A stored procedure retrieves all orders for a customer by joining Orders and Customers tables. Which option improves performance by reducing unnecessary data retrieval?
Testing Fundamentals
CREATE PROCEDURE GetCustomerOrders @CustomerID INT AS BEGIN SELECT * FROM Orders INNER JOIN Customers ON Orders.CustomerID = Customers.ID WHERE Customers.ID = @CustomerID; END;
ASELECT Orders.* FROM Orders WHERE CustomerID = @CustomerID;
BSELECT * FROM Orders INNER JOIN Customers ON Orders.CustomerID = Customers.ID;
CSELECT Customers.*, Orders.* FROM Customers LEFT JOIN Orders ON Customers.ID = Orders.CustomerID WHERE Customers.ID = @CustomerID;
DSELECT * FROM Orders WHERE CustomerID = @CustomerID;
Attempts:
2 left
💡 Hint
Avoid joining tables if not needed and select only required columns.
🔧 Debug
advanced
2:00remaining
Debugging a stored procedure with parameter issues
A stored procedure is supposed to update an employee's salary but does not change any data when called. Which option explains the likely cause?
Testing Fundamentals
CREATE PROCEDURE UpdateSalary @EmpID INT, @NewSalary DECIMAL(10,2) AS BEGIN UPDATE Employees SET Salary = @NewSalary WHERE EmployeeID = @EmpID; END;
AThe Employees table does not have a Salary column.
BThe procedure is missing a COMMIT statement after UPDATE.
CThe parameter names in the procedure call do not match those in the procedure definition.
DThe procedure lacks a WHERE clause, so no rows are updated.
Attempts:
2 left
💡 Hint
Check if the parameters passed when calling the procedure match the defined names.
🧠 Conceptual
expert
3:00remaining
Understanding transaction handling in stored procedures
Which option best describes what happens if a stored procedure contains multiple UPDATE statements inside a transaction and one UPDATE fails?
AAll previous successful UPDATEs are rolled back, leaving the database unchanged.
BOnly the failed UPDATE is rolled back; previous UPDATEs remain committed.
CThe transaction commits all changes regardless of failure.
DThe procedure stops but changes before failure remain uncommitted and visible.
Attempts:
2 left
💡 Hint
Think about atomicity in transactions.