Translate

Wednesday, August 29, 2012

What is the difference 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) Function takes one input parameter it is mandatory but stored procedure may take o to n input parameters.

4) Functions can be called from select statement, but stored procedures can not be called from select statement. 

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

No comments:

Post a Comment