What is the difference between function and stored procedure?Ask Questions

 Posted on 08/03/2018

                                                                                                                                                                                                                 
Share On: facebook gplus twitter
profile
Asked by Hardik Parekh on 08/03/2018 Score: 234 points
Add Comment:

Comments

1 Answers

1 Corrected Answers
Aproved Answers
3
Profile
Answered by Shailesh Chaudhary on 8/3/2018 8:31:11 AM Score: 800 points

  • Function must return a value but in Stored Procedure it is optional( Procedure can return zero or n values).
  • Functions can have only input parameters for it whereas Procedures can have input/output parameters .

  • Functions can be called from Procedure whereas Procedures cannot be called from Function

  • Procedure allows SELECT as well as DML(INSERT/UPDATE/DELETE) statement in it whereas Function allows only SELECT statement in it.

  • Procedures can not be utilized in a SELECT statement whereas Function can be embedded in a SELECT statement.

  • Stored Procedures cannot be used in the SQL statements anywhere in the WHERE/HAVING/SELECT section whereas Function can be.

  • Functions that return tables can be treated as another rowset. This can be used in JOINs with other tables.

  • Inline Function can be though of as views that take parameters and can be used in JOINs and other Rowset operations.

  • IException 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.


Comments

Add Comment:

Post Your Answers

Existing Members

Sign in to your account
Email Address
Password
New Member?
Sign up and complete profile
Full Name
Email Address
I have read and agree to the Terms of Service and Privacy Policy
Please subscribe me to the StoodQ newsletters
Guideline to answer a question:

Useful tips to submit your answer
Please read below guidelines before you submit your answer for question.

  • Read and understand question for which you are submitting your answer.
  • Try to avoid grammatical and spell mistake while answering.
  • Do not post any irrelevant information in your answer.
  • Explain your answer with example or any reference link to help who posted question.
  • If you find irrelevant question, please report it to support. Click here to contact support.
  • You agree to the privacy policy and terms of use to submit any contents.

Note: StoodQ is online developers community which helps developer for their difficulty, lets help them with your value contribution.