HomeInterview QuestionsWhat is a stored procedure?

What is a stored procedure?

🟢 Easy Conceptual Fresher level
1Times asked
Jun 2026Last seen
Jun 2026First seen

💡 Model Answer

A stored procedure is a precompiled set of SQL statements that reside in the database and can be executed by name. It can accept input parameters, return result sets or output parameters, and encapsulate business logic. Using stored procedures improves performance by reducing network round trips, allows the database engine to optimize execution plans, and centralizes logic for easier maintenance. It also enhances security by granting users execute rights on the procedure while restricting direct table access. Example: CREATE PROCEDURE GetEmployee @id INT AS SELECT * FROM Employees WHERE EmployeeID = @id; Then call it with EXEC GetEmployee 5. The procedure runs in O(1) time for the call itself, but the underlying SELECT’s complexity depends on indexes and data size.

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