Function Vs Stored Procedure

Difference between Function and Stored Procedure

Functions

  • Compiled and executed at Run time.
  • Can not affect the Database state. i.e Can not perform insert,delete and update operation.
  • Can return 1 value which is mandatory.
  • Can have Input parameters only.
  • Function can not call Stored Procedure .
  • Exception can not be handled by using try/catch block.
  • Can not go for Transaction Management.
  • Functions can be embeded in Select statement.

Stored Procedure

  • Stored in Parsed and compiled format in database.
  • Can Affect the database state by using DML commands.
  • Can return 0 or n value .
  • Can have Input and output parameters.
  • Stored Procedure can call Function .
  • Exception can be handled by using try/catch block.
  • Can go for Transaction management.
  • It can not be embeded in Select statement.
Advertisements

About Gokul Dahal, Nepal

Software Engineer, Freelancer, Design and Develop web applications,Software Developer Nepal, FreeLancer Nepal Contact : gokuldahal@gmail.com
This entry was posted in SQL and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s