Difference between Stored procedure and Function in SQL

Following are the main differences between Stored procedure and Function in SQL.

Stored Procedure Function
Stored procedure may or may not return values A Function must return a value
Stored procedures can have input/output parameters Functions can have only input parameters
Stored Procedure may take 0 to n input parameters For a Function it is mandatory to take one input parameter
Procedures cannot be called from a Function Functions can be called from a Procedure
Exceptions can be handled by try-catch blocks in a Procedure try-catch block cannot be used in a Function
A Procedure allows SELECT as well as DML (INSERT, UPDATE, DELETE) statements in it Function allows only SELECT statement in it
Stored procedure can return multiple values Functions returns only one value

Leave a Reply

Your email address will not be published. Required fields are marked *