TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Difference between Stored Procedure and Function
Jaipal Reddy
Jun 13, 2015
3.6
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
In this blog you will learn the basic differences between Stored Procedure and Function.
The difference between Stored Procedure and Function is one of the most common interview question. In this article you will learn the basic differences between Stored Procedure and Function.
Stored Procedure
Stored Procedure may or not return values.
Procedures Can have select statements as well as DML statements such as insert, update, delete and so on.
Procedures can have both input and output parameters.
For exception handling we can use try catch blocks.
Can use transactions within Stored Procedures.
Procedures Can use both table variables as well as temporary table in it.
Stored Procedures can call functions.
Procedures can't be called from Select/Where/Having and so on statements. Execute/Exec statement can be used to call/execute Stored Procedure.
Procedures can't be used in Join clause.
Function
Function must return a value.
Will allow only Select statements, it will not allow us to use DML statements.
It will allow only input parameters, doesn't support output parameters.
It will not allow us to use try-catch blocks.
Transactions are not allowed within functions.
We can use only table variables, it will not allow using temporary tables.
Stored Procedures can't be called from a function.
Functions can be called from a select statement.
A UDF can be used in join clause as a result set.
Please give your valuable suggestions and feedback.
Difference between Stored Procedure and Function
Next Recommended Reading
Difference Between Stored Procedures and Triggers