1
What is Difference between STORED PROCEDURE vs FUNCTION?
What is Difference between STORED PROCEDURE vs FUNCTION?
The difference between a Stored Procedure and a Function mainly comes down to how they behave, what they return, and how you use them in SQL.
Stored Procedure:
Function:
Stored Procedure:
SELECT, WHERE, etc.CALL or EXECFunction:
SELECT my_function(column_name) FROM table;
Stored Procedure:
Function:
Stored Procedure:
Function:
Stored Procedure:
CALL procedure_name();
Function:
SELECT function_name();
Stored Procedure:
Function:
| Feature | Stored Procedure | Function |
|---|---|---|
| Return value | Optional / multiple | Mandatory (single) |
| Use in SELECT | No | Yes |
| Data modification | Allowed | Restricted |
| Parameters | IN, OUT, INOUT | Mostly IN only |
| Purpose | Perform actions | Return value |