Basic Stored Procedure in SQL

Yash Jain
CodingWithYash
Published in
2 min readJan 22, 2020

What is Stored Procedure?

Stored Procedure is nothing new, they are just like functions and methods, & can have arguments as well.

Stored Procedure like functions has a motive that is to be used to execute a query multiple times by calling procedure.

A query is written within the procedure and can also able to output certain values and number of columns depending upon the requirement.

Syntax of Procedure

When the query is of the single line only -

When the query is of multiple lines -

Here is a small example of a procedure to understand how it works -

Without BEGIN & END

→ Drop Procedure (To make sure there is no procedure with this name exists)

→ Create Procedure

→ Execute Procedure

→ To view the resulting value

With BEGIN & END

→ Drop Procedure (To make sure there is no procedure with this name exists)

→ Create Procedure

→ Execute Procedure

→ To view the resulting value

This is the basic example of a procedure with which you can begin to understand how procedure works.

--

--