Below are few differences between Stored Procedure and Function
1) Stored procedure are compiled for first time and compiled format is saved and executes compiled code when ever it is called. But function is compiled and executed every time it is called.
2) Function must return a value but in stored procedure it is optional.
3) Functions can be called from select statement, but stored procedures can not be called from select statement.
4) We can build logic in functions and we can even break complex logic in to methods.
5) We can use try catch statements in stored procedures but in functions we can not use.
6) We can not use insert,delete,update and create statements in functions but in stored procedures we can use those statements.
7 ) Functions can have only input parameters but stored procedure can have input and out put parameters
8) You can use UDF in Join but we can not use Stored procedure in Join
No comments:
Post a Comment