Home / Others / Function vs Stored Procedure in SQL
Function vs Stored Procedure in SQL

What is the different between Stored Procedure and Function?. This is the important question which asked in interview most of the time. We are going to share top 10 differences of Stored Procedure and Function.

1. Function must return a value but in Stored Procedure can return zero or n values.

2. Functions can have only input parameters but Procedures can have input/output parameters.

3. Functions can be called from Procedure whereas Procedures cannot be called from Function.

4. Procedure use DML(INSERT/UPDATE/DELETE) statements in it but Function allows only SELECT statement in it.

5. Function can be embedded in a SELECT statement, but we cannot use Procedures in SELECT statement.

6. Function can be used anywhere in the WHERE/HAVING/SELECT section, but not with Procedure.

7. Functions that return tables can be treated as another rowset, can be used in JOINs.

8. Try-Catch block can be use in Procedure but not in Function.

9. Transaction Management can be use in Procedure but not in Function.

10. Function returns 1 value only. Procedure can return multiple values (max 1024).