Sunday, March 25, 2012

What are basic differences between Stored Procedures and Functions in SQL?

1. Procedure may return none or more values. Function must always return one value either a scalar value or a table.
    

2. Procedure have input, output parameters.Functions have only input parameters.
    

3. Stored procedures are called independently by EXEC command whereas Functions are called from within SQL statement.
    

4. Functions can be called from procedure. Procedures cannot be called from function.
    

5. Exception can be handled in Procedure by try-catch block but try-catch block cannot be used in a function.    

6. Transaction management possible in procedure but not in function.

No comments: