Difference between Stored Procedure and User Defined Function in Sql Server

 Posted by Niladri.Biswas on 5/15/2013 | Category: Sql Server Interview questions | Views: 1244 | Points: 40

1)Function must return a value.Stored procedure may or not return values.

2) Functions will allow only Select statement, it will not allow us to use DML statements.
Stored Procedures can have select statements as well as DML statements such as insert, update, delete etc

3)Functions will allow only input parameters, doesn’t support output parameters.But Stored Procedures can have both input and output parameters.

4) Transactions are not allowed within functions.We can use transactions within Stored procefures.

5) Stored procedures can’t be called from function.Stored Procedures can call functions.

6) UDF can be used in join clause as a result set.Procedures can’t be used in Join clause

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response