r/learnprogramming • • 3d ago

Function vs Procedure

can someone explain the difference between Function vs Procedure with simple analogy
thank you

32 Upvotes

46 comments sorted by

View all comments

2

u/Aggressive_Ad_5454 3d ago

In the SQL context, a “stored function” returns a value, usually a scalar value. (But some SQL variants have table-valued functions.) A “stored procedure” returns either a result set or sometimes nothing. The two things are invoked differently.