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
Executing stored procedure
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:
To Execute the above stored procedure, we have to declare a variable for output parameter and specify the parameter as out
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
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/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.