Blog Post

Sql Server- Difference between Stored Procedure and Function

,

In Sql Server, both functions and stored procedures can be defined as the logically grouping of Sql statements formed to complete a task, but still there are many differences between Stored procedure and Functions.
These differences can be summarized as follows:-
1) A stored procedure can return a value or it may not return any value but in case of function, a function has to return a value.
2) Stored procedure in Sql Server can not we executed within the DML statement.It has to be executed with the help of EXEC or EXECUTE keyword but a function can be executed within the DML statement. 
3) Functions can be called from within the Stored Procedure but a stored procedure can not be called from within a function.
4) A stored procedure can return multiple parameters but a function can return only one value.
5) We can use join in the outcome from the functions but we can't use joins in the outcome from stored procedures.
6) Transaction management is not possible in functions but it is possible in Stored procedures.
7)Print function can not be called within the function but it can be called within the stored procedure.

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating