Stored Procedures in SQL: Example
Stored Procedures in SQL: Example
Stored procedures are prepared SQL code that you save so you can
reuse it over and over again. So if you have an SQL query that you
write over and over again, save it as a stored procedure and call
it to run it. You can also pass parameters to stored procedures so
that the stored procedure can act on the passed parameter values.
Stored Procedures are created to perform one or more DML operations
on Database. It is nothing but the group of SQL statements that
accepts some input in the form of parameters and performs some task
and may or may not return a value.
Syntax
CREATE PROCEDURE procedure_name
(parameter1 data_type, parameter2 data_type, …)
AS
BEGIN
— SQL statements to be executed
END
To Execute the procedure
EXEC procedure_name parameter1_value, parameter2_value, ..
Parameter Explanation
Example: