- In Stored procedures , RETURN keyword is used but without any value being passed.
- Functions return a value (using the RETURN keyword), but for stored procedures this is not compulsory.
- A function is a subprogram written to perform certain computations and return a single value.
- Functions could be used in SELECT statements, provided they donít do any data manipulation. procedures cannot be included in SELECT statements.
- A function can have only IN parameters, while stored procedures may have OUT or INOUT parameters.
- A stored procedure can return multiple values using the OUT parameter or return no value at all.
Stored Procedures Comparison with view
- View can be used as a table object A procedure cannot be used as a table object.
- you cannot accept parameters and do looping inside a view. you can accept parameters and do looping inside a procedure
There are following advado.netage of stored procedure:
- Execution plan retention and reuse
- Query auto-parameterization
- Encapsulation of business rules and policies
- Application modularization
- Sharing of application logic between applications
- Access to database objects that is both secure and uniform
- Consistent, safe data modification
- Network bandwidth conservation
- Support for automatic execution at system start-up
- Enhanced hardware and software capabilities
- Improved security
- Reduced development cost and increased reliability
- Centralized security, administration, and maintenance for common routines
If you wado.net to switch to using another vendor's database, then you have to rewrite your stored procedures. Stored procedures are easy to misuse. If you place business logic in them, then you are not separating business logic from data logic - a maintenance headache. There are emerging alternatives to them that remove some of the disadvado.netages - such as LINQ in the Microsoft .NET world