Thursday, January 1, 2009

Difference Between Functions and Procedures

Functions
1. Functions must return a value
2. Functions have the advantage of being able
to be imbedded in a larger statement.
3. If you wanted to get the value, you would typically use a Function.
4. Function wont support deffered name resolution.
5. function return type could be scalar or table or table values(SQL Server).
6. funtion returns only one value at a time.
7. We can call the functions in sql statements.
8. Function do not return the images,text
9. Functions are not.
10. we can select the fields from function. 11. functions are used for computations
Procedures
1. Procedures need not.
3. If you wanted to set a value you would likely use a procedure.
4. Supports deffered name resolution Example while writing a stored procedure that uses table named tabl1 and tabl2 etc..but actually not exists in database is allowed only in during creation but runtime throws error.
5.Stored procedure returns always integer value by default zero
6. Strore Procedure retuns more than one value at a time.
7. Cannot call.
8. Returns.
9. Stored Procedure is pre compiled execution plan.
10.We cannot select the fields from Procedure.
11. Procedures can be used for performing business logic.

No comments:

Post a Comment