Stored Procedures
What are Stored Procedures ?
A Stored Procedure is a prepared SQL code that we can save, so the code can be reused over and over again.
Instead, of writing the SQL Query again and again, we can save it as a stored procedure, and then just call it to execute it.
We can pass parameters to a stored procedure, so that the stored procedure can act based on the parameter values(s) that is passed.
Syntax :
CREATE PROCEDURE procedure_name
AS
sql_statement
Example :
CREATE PROCEDURE CustomersProcedure
AS
SELECT * FROM Customers
Execute a Stored Procedure :
EXEC procedure_name
Example :
EXEC CustomersProcedure