RSS

Differences between Stored Procedures and Functions

05 Apr
  • Procedure can return zero or n values whereas function can return one value which is mandatory.
  • Procedures can have input/output parameters for it whereas functions can have only input parameters.
  • Procedure allows select as well as DML statement in it whereas function allows only select statement in it.
  • Functions can be called from procedure whereas procedures cannot be called from function.
  • Exception can be handled by try-catch block in a procedure whereas try-catch block cannot be used in a function.
  • We can go for transaction management in procedure whereas we can’t go in function.
  • Procedures can not be utilized in a select statement whereas function can be embedded in a select statement.
  • UDF can be used in the SQL statements anywhere in the WHERE/HAVING/SELECT section where as Stored procedures cannot be.
  • UDFs that return tables can be treated as another rowset. This can be used in JOINs with other tables.
  • Inline UDF’s can be though of as views that take parameters and can be used in JOINs and other Rowset operations.
Advertisements
 
2 Comments

Posted by on April 5, 2013 in SQL

 

2 responses to “Differences between Stored Procedures and Functions

  1. Sumit

    April 5, 2013 at 8:57 am

    Good Start………

     
  2. Emil Schlimmer

    April 7, 2013 at 11:32 am

    Hey mate ! I just saw your web-site and all I can say is that is very nice. Lots of beneficial info on it. I also see that you dont rank very good in the searchengines. You can use this simple plugin for wordpress to take your website higher in the search engines – http://url-short.net/wpseo -. In case you need any help with this plugin send me an E mail.

     

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

 
%d bloggers like this: