Monday, 13 July 2015

Difference between Stored Procedures and User Defined Functions

STORED PROCEDURES
USER DEFINED FUNCTIONS
Stored Procedures May or May not Return the Values.
Functions Must Return a Value.
Stored Procedures will have Input and Output Parameters.
Function Can have only Input Parameters.
Stored Procedures Cannot be called from Functions.
Functions can be called from Stored Procedures.
Stored Procedures Allow Select as well as DML (Insert/Update/Delete) Statements in it.
Function allows only Select Statements.
Stored Procedures cannot be called from Select/ Where/Having etc statements.
Functions can be called from Select Statement.
Exceptions can be handled by try-catch block in stored procedure.
Try-Catch block cannot be used in a Function.
We can use Transactions with in the Stored Procedures.
Function won't allow Transactions.
Procedures cannot be used in join clause.
Functions that returns the table can be treated as another row set. And this can be used in JOINS with another table.


No comments:

Post a Comment