SQL Tutorial

SQL Stored Procedure

Introducing to Stored Procedure

A stored procedure by definition is a segment of code which contains declarative or procedural SQL statement.

Getting Started with Stored Procedure

You will learn how to write the first stored procedure and how to call it.

Parameter List in Stored Procedure

A stored procedure can have zero, one or more than one parameters. If a stored procedure has more than one parameter, each one must be separated by a comma.

Body in Stored Procedure

The body part of a stored procedure is where you can put your business logic codes inside to execute it as you want it to do.

Local Variables

Local variables are used in stored procedure to keep temporary intermediate results.

Common Usage Flow-Control in Stored Procedure

In this section, we will cover all basic flow-control statement which can be used in stored Procedure. There are two most common usage of flow-control which are conditional execution and loop.

Modifying and Compiling Stored Procecdure

Once a stored procedure is resided in the database server catalog, we can modify it by using the ALTER PROCEDURE statement or remove it by using DROP PROCEDURE. You can recompile the stored procedure by using WITH RECOMPILE.