A stored procedure is a prepared SQL code that can be saved and reused over and over again 1. It is a named collection of SQL statements and procedural logic that is compiled, verified, and stored in the server database 2. Stored procedures are typically treated like other database objects and controlled through server security mechanisms 2.
Advantages
- Easy to maintain. Business logic that is stored in SP can be used multiple times in another various chances or application. If there is changes in business logic, the change can be immediately done in SP and all application that used SP can be directly accommodate the changes as well without alter one by one.
- Safety. Access to SP can be shared to users that does not have the table access in SP
Practice
Loop Practice
Conditional Statement (IF THEN)