Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Difference between Stored Procedure and Function
WhatsApp
Jaipal Reddy
9y
3.7
k
0
0
25
Blog
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
Up Next
Difference Between Stored Procedures and Triggers
Ebook Download
View all
Introducing Microsoft SQL Server 2016
Read by 11k people
Download Now!
Learn
View all
Membership not found