You are on page 1of 1

What is a Stored Procedure?

A stored procedure is a prepared SQL code that you can save, so the code can be reused 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 then just call it to execute it.

You can also pass parameters to a stored procedure, so that the stored procedure can act based on
the parameter value(s) that is passed.

What is basic Syntax of Stored Procedure

Stored Procedure Syntax


CREATE PROCEDURE procedure_name
AS
sql_statement
GO;
Execute a Stored Procedure
EXEC procedure_name;

Where the stored procedures are stored in database?


In a DBMS, a stored procedure is a set of SQL statements with an assigned name that's stored in
the database in compiled form so that it can be shared by a number of programs. for
simple, Stored Procedure are Stored Programs, A program/function stored into database

what is difference between stored procedure and function in sql


1. The function must return a value but in Stored Procedure it is optional. Even a
procedure can return zero or n values.
2. Functions can have only input parameters for it whereas Procedures can have input or
output parameters.
3. Functions can be called from Procedure whereas Procedures cannot be called from a
Function.

You might also like