What is the difference between Stored Procedure and Function?

562 viewsSQLSQL
0
Gautam Sarswat Changed status to publish January 11, 2023
0

1. A procedure can have both input and output parameters, but a function can only
have input parameters.
2. Inside a procedure we can use DML (INSERT/UPDATE/DELETE) statements. But
inside a function we can’t use DML statements.
3. We can’t utilize a Stored Procedure in a Select statement. But we can use a function
in a Select statement.
4. We can use a Try-Catch Block in a Stored Procedure but inside a function we can’t
use a Try-Catch block.
5. We can use transaction management in a procedure but we can’t in a function.
6. We can’t join a Stored Procedure but we can join functions.
7. Stored Procedures cannot be used in the SQL statements anywhere in the
WHERE/HAVING/SELECT section. But we can use a function anywhere.
8. A procedure can return 0 or n values (max 1024). But a function can return only 1
value that is mandatory.
9. A procedure can’t be called from a function but we can call a function from a
procedure.

Gautam Sarswat Changed status to publish January 11, 2023
You are viewing 1 out of 1 answers, click here to view all answers.
Write your answer.

Posted

in

Tags:

Comments

Leave a Reply

A Tribute to Dilip Kumar