What is the Difference between a Function and a Stored Procedure?


Stored procedure

  • Stored procedure can execute function.
  • Stored procedure may or may not return value.
  • Stored procedure can execute DDL Commands (Drop, Create, Alter etc.)
  • Stored procedure can not be used in any SQL statement like Select/Where/Having.
  • Stored procedure can use try/catch block.
  • Stored procedure can use Transaction.

Function

  • Function can not execute Stored procedures.
  • Function always return value.
  • Function can not execute DDL Commands (Drop, Create, Alter etc.)
  • Function can be used in SQL statements like Select/Where/Having.
  • Function can not use try/catch block.
  • Function can not use Transaction.