SQL Function VS StoredProcedure


Question

What is the difference between SQLStored Procedure and SQLFunction?

Answer

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.

Comments

Popular posts from this blog

sp_addmessage can be used to create a User-Defined Error Message

Command-line Building With csc.exe

Prepare DTO layer by using below script