PrepZone Logo
PrepZone
Back to Database

Database · Medium

Difference between stored procedures and functions in SQL. When should you use each?

DatabaseSQLFresher

Answer preview

Both are named blocks of SQL/procedural code stored in the database. A function is designed to compute and return a value and can be called inside a query; a procedure is designed to perform actions, is invoked with CALL, and can manage transactions with COMMIT/ROLLBACK.…