Google Analytics Alternative

Search This Blog

Thursday, November 10, 2011

SQL Function VS StoredProcedure


What is the difference between SQLStored Procedure and SQLFunction?


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.

No comments: