Have you ever thought what happens when your queries get to the database?. They are actually compiled each time you query and then executed. If you think about it, you will find that this is not the ideal approach. A much better solution would be to have the database server compile the query, store it in a compiled format and run it on request, without having to recompile it each and every time. This is where the concept of stored procedures comes into play.
In this article we are going to learn how stored procedures work, what the benefits of using stored procedures are, and also how to create simple as well as complex stored procedures that accept and return parameters. In this article I will be focusing on using Microsoft SQL Server, however many of the principles in this article can also apply to other RDBMS's such as Oracle.
Near the end of this article we will learn how to make changes to a stored procedure and drop existing stored procedures .By the end of this article you will be fully prepared to start using basic stored procedures in your applications.