Different between Function() and Store Procedure()

  • Stored procedures can return zero, one, or more values. While a function must return a single value (possibly a table).

  • Functions can only have input parameters to it while stored procedures can have input or output parameters.

  • Function can be called from stored procedure while stored procedure cannot be called from function.

  • Procedures cannot be used in SELECT statements while functions can be embedded in SELECT statements. Because a procedure can return multiple result sets, it is not suitable for use in SELECT statements.

  • Stored procedures cannot be used in WHERE / HAVING / SELECT statements while functions can.

  • An exception can be handled by try-catch in a stored procedure, not for a function.

  • Transactions can be used in stored procedures, not possible with functions.

Last updated