Home > DeveloperSection > Interviews > Difference Between Procedure Vs Function in the Database

Posted on    November-07-2015 1:41 AM

 Database Database Design 
 1 Answer(s)
  815  View(s)
Rate this:

Anupam Mishra

Total Post:23

Posted on    November-07-2015 2:41 AM


The point of differences between procedure and function are as follows:

1.  A function has a return type, while procedure does not have any return type.However ,If needed, the data can be made available to the client through one or more OUT parameters.

2 A function can be used with SQL DML queries,but not the procedures..

3.A function is not suitable to use DML queries,but can be used in procedures. The use of DML queries in function is not completely restricted.
4.Exception can be handled by try-catch block in a procedure whereas try-catch block cannot be used in a function.
5. We can go for transaction management in procedure whereas we can't go in function.
6.Procedures can not be utilized in a select statement whereas function can be embedded in a select statement.
7.UDF can be used in the SQL statements anywhere in the WHERE/HAVING/SELECT section where as Stored procedures cannot be.
8.UDFs that return tables can be treated as another rowset. This can be used in JOINs with other tables.
9. Inline UDF's can be though of as views that take parameters and can be used in JOINs and other Rowsetoperations.



Modified On Mar-17-2016 01:36:37 AM

Don't want to miss updates? Please click the below button!

Follow MindStick