Tuesday, January 31, 2012

D/f sql functions and stored procedures


we cant use DML operations in functions where as it is possible in sp.
Procedure can return zero or n values whereas function can return one value which is mandatory.
error handling can be done in sp, but not possible in function.
functions can be called from select statements, where clause and case but not possible in sp.
Procedures can have input,output parameters for it whereas functions can have only input parameters
Functions can be called from procedure whereas procedures cannot be called from function.
We can go for transaction management in procedure whereas we can't go in function.


1. Functions are compiled and executed at run time.
Stored procedures are stored in parsed and compiled format in the database.

2. Functions cannot affect the state of the database which means we cannot perform insert,delete,update and create operations on the database.
Stored Procedures can affect the state of the database by using insert,delete,update and create operations.

3 Functions are basically used to compute values. We passes some parameters to functions as input and then it performs some operations on the parameter and return output.
Stored procedures are basically used to process the task.

4.Function can not change server environment and our operating system environment.
Stored procedures can change server environment and our operating system environment.

5.Functions can not be invoked from SQL Statements. Execute. SELECT
operating system can be invoked from SQL Statements. Execute. SELECT

6.Functions can run an executable file from SQL SELECT or an action query.
operating system use Execute or Exec to run
 

No comments :

Post a Comment