Creating a simple stored procedure
Stored procedures are database objects that allow us to encapsulate a set of SQL statements and execute them directly on a server. A stored procedure resides in a database server, so when we execute it, it is executed locally. We can implement any business logic or application logic inside a stored procedure and keep it in the database. It can be invoked from any client application. Stored procedures can accept input parameters and return output parameters or result sets or both. In this recipe, we will see how to create a simple stored procedure.
We can define a stored procedure in the following three ways:
External procedures: The procedure body is written in a high-level programming language for external procedures
Sourced procedures: They are also known as federated procedures, where the definition of a procedure is based on another procedure that resides on a different server, accessible via federation
SQL: The procedure body is written in SQL