SQL – Stored Procedure 📦

SQL is the standard language for the Relational Database, for storing, manipulating and retrieving stored data. For basics of SQL (link)

A Stored Procedure is a SQL code that we can save, so the code can be reused again and again.
So, if we have any …


This content originally appeared on DEV Community and was authored by Sharanjeet kaur

SQL is the standard language for the Relational Database, for storing, manipulating and retrieving stored data. For basics of SQL (link)

A Stored Procedure is a SQL code that we can save, so the code can be reused again and again.
So, if we have any SQL query which we write over and over again, we can use it as a stored procedure so that we can just call it to execute it.

The Syntax for creating the stored procedure

Image description

Executing stored procedure

Image description

Stored Procedure with Parameters

To add Parameters in the procedure, first, we need to alter the procedure for which we can use ALTER procedure statement as follows:

Image description

To Execute the above stored procedure, we have to declare a variable for output parameter and specify the parameter as out

Image description

Just like this, we can also set multiple parameters by separating each parameter and the data type with a comma

Drop a stored procedure

To drop a stored procedure, use the DROP statement as follows:

DROP PROCEDURE usp_proc;

Thank you!! Feel free to comment on any type of feedback or error you have 😄✌


This content originally appeared on DEV Community and was authored by Sharanjeet kaur


Print Share Comment Cite Upload Translate Updates
APA

Sharanjeet kaur | Sciencx (2021-10-27T06:54:52+00:00) SQL – Stored Procedure 📦. Retrieved from https://www.scien.cx/2021/10/27/sql-stored-procedure-%f0%9f%93%a6/

MLA
" » SQL – Stored Procedure 📦." Sharanjeet kaur | Sciencx - Wednesday October 27, 2021, https://www.scien.cx/2021/10/27/sql-stored-procedure-%f0%9f%93%a6/
HARVARD
Sharanjeet kaur | Sciencx Wednesday October 27, 2021 » SQL – Stored Procedure 📦., viewed ,<https://www.scien.cx/2021/10/27/sql-stored-procedure-%f0%9f%93%a6/>
VANCOUVER
Sharanjeet kaur | Sciencx - » SQL – Stored Procedure 📦. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/10/27/sql-stored-procedure-%f0%9f%93%a6/
CHICAGO
" » SQL – Stored Procedure 📦." Sharanjeet kaur | Sciencx - Accessed . https://www.scien.cx/2021/10/27/sql-stored-procedure-%f0%9f%93%a6/
IEEE
" » SQL – Stored Procedure 📦." Sharanjeet kaur | Sciencx [Online]. Available: https://www.scien.cx/2021/10/27/sql-stored-procedure-%f0%9f%93%a6/. [Accessed: ]
rf:citation
» SQL – Stored Procedure 📦 | Sharanjeet kaur | Sciencx | https://www.scien.cx/2021/10/27/sql-stored-procedure-%f0%9f%93%a6/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.