Saturday, December 22, 2012

Difference between Function and Stored Procedure

Today, i am listing down just the basic difference between Function and Stored Procedure often asked in interviews.




Function Stored Procedure
1 Function always needs to return the value Stored Procedure may or may not return the value
2 Function can be called from within the Stored Procedure Stored Procedure cannot be called from Function
3 Function cannot have any DML statement i.e. it cannot be used for Data Manipulation in Tables Stored Procedure can have DML statements i.e. it can be used to perform Data Manipulation in Tables
4 Function cannot have an output parameter Stored Procedure may or maynot have an output parameter defined
5 Function can be called directly in Select statement Stored Procedure can be called using EXEC or EXECUTE keyword


Hope this helps !!

No comments:

Post a Comment