Write a stored procedure that accepts a department ID and returns the employee name, department name, and salary.
1Times asked
Jun 2026Last seen
Jun 2026First seen
💡 Model Answer
A straightforward procedure:
sql
CREATE PROCEDURE dbo.GetEmployeesByDept
@DeptID INT
AS
BEGIN
SELECT d.DepartmentName,
e.EmployeeName,
e.Salary
FROM Employees e
JOIN Departments d ON e.DepartmentID = d.DepartmentID
WHERE e.DepartmentID = @DeptID;
END;This returns all employees in the specified department. Complexity is O(m) where m is the number of employees in that department. Call it with EXEC dbo.GetEmployeesByDept @DeptID = 3;.
This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.
🎤 Get questions like this answered in real-time
Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers — invisible to screen sharing.
Get Assisting AI — Starts at ₹500