Sr. No
|
STORED PROCEDURE
|
Functions
|
1
|
Stored procedure are compiled
for first time and compiled
format is saved and executes
compiled code whenever it is
called
|
But function is compiled and executed every time it is called.
|
2
|
Stored Procedures may or may
not return values. In stored
procedure it is optional
|
Function must return a value
|
3
|
Stored Procedures may take 0 to
n input parameters
|
Function takes one input parameter it is mandatory
|
4
|
SPs can not be called from
select statement
|
Functions can be called from select statement
|
5
|
break complex logic in to SPs
|
We can build logic in functions
|
6
|
We can use try catch statements
in stored procedures
|
but in functions we can not use
|
7
|
We can use insert, delete,
update and create statements in
functions
|
We cannot use insert, delete, update and create statements in functions
|
8
|
SPs can have input and output
parameters
|
Functions can have only input parameters
|
Saturday, July 28, 2012
Differences between Stored Procedure and Function
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment