A stored procedure is a collection of SQL statements saved in the database and executed as a single unit. It improves performance, security, and code reusability.
- Accept input parameters
- Perform logic (SELECT / INSERT / UPDATE / DELETE)
- Return results or output parameters
1.Why Use Stored Procedures?
✔ Faster execution (precompiled)
✔ Reusable SQL logic
✔ Better security (grant access without table access)
✔ Easier maintenance
✔ Reduce network traffic
2.Basic Syntax
3.Create a Simple Stored Procedure
Example Table: Employees
| EmployeeID | Name | Department | Salary |
|---|---|---|---|
| 1 | John | IT | 50000 |
| 2 | Jane | HR | 45000 |
