What is the difference between Stored Procedure and Function in SQL?

Stored Procedure VS Function

Stored Procedure VS Function in SQL
Sr.Stored Procedure (SP)Function
1SP have both input and output parametersFunction only have input parameters
2SP return 0 or n valuesFunction return only 1 value that is mandatory
3SP can’t be called from a functionFunction can be called from a procedure.
4Inside a procedure we can use DML (INSERT/UPDATE/DELETE) statementsInside a function we can’t use DML statements
5SP can’t be used in a Select statementFunction can be used in a select statements
6SP can’t be used anywhere in the WHERE/HAVING/SELECT section in SQLFunction can be used in WHERE/HAVING/SELECT section in SQL statements
7SP can include or use TRY CATCH blockFunction can’t use TRY CATCH bock
8SP can use transaction managementFunction can’t use transaction management
9We can’t join Stored ProceduresWe can join Functions
Stored Procedure VS Functions

Leave a Reply

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