top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is the Difference between a Function and a Stored Procedure?

+2 votes
563 views
What is the Difference between a Function and a Stored Procedure?
posted Jan 21, 2014 by Vishvachi Tiwari

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote
 
Best answer

Stored Procedures are pre - compile objects which are compiled for first time and its compiled format is saved which executes (compiled code) whenever it is called. But Function is compiled and executed every time when it is called.

answer Jan 21, 2014 by Atul Mishra
0 votes

1.Stored procedure is stored as the pre-compiled block of statements after first compilation and executes it whenever called where as Function is compiled each time and then executed .
2. SP can also call funtion , same is not possible via function.
3. SP is used for select , insert or update query while function only includes select.
4. SP may or may not return any result function always returns result.
5. SP can include input nad output parameters while function inludes only input parameter.
6. We can use try catch block in SP for the exception but we cant do the exception handling in function.

answer Mar 5, 2017 by anonymous
...