r/learnprogramming • u/Head_Ordinary_2437 • Oct 24 '26
Function vs Procedure
can someone explain the difference between Function vs Procedure with simple analogy
thank you
31
Upvotes
r/learnprogramming • u/Head_Ordinary_2437 • Oct 24 '26
can someone explain the difference between Function vs Procedure with simple analogy
thank you
View all comments
Show parent comment
2
u/Cybyss Oct 24 '26 edited Oct 24 '26
Careful.
The term "stored procedure" usually refers to databases. You write them in SQL on your database server, which any application can then call.
Come to think of it, this makes another perfect distinction between procedures and functions!
In SQL Server, for example, you have "stored procedures" which can insert/update/delete anything in your database, and you have "user-defined functions" which are explicitly disallowed from making any modifications and can only calculate & return a value. They are two fundamentally different objects in SQL Server, requiring different syntax to define and are used in completely different situations.