Monday 12 September 2016

Stored Procedures vs Functions

Stored ProceduresFunctions
Stored Procedure can have both input and output parameters.Function can have only input parameters.
We can call Function from Stored Procedure.We can't call Stored Procedure from Function.
Exceptions can be handled by using try-catch blockWe can't use try-catch block in Functions.
It may return or may not return a value.It must be return a value.
Stored Procedure can use transaction.Function can't use transaction.
Stored Procedure are pre-compiled set of SQL statements.Functions are not pre-compiled, we need to compile and execute every time.
Procedure can work with Insert, Update, Delete, Select statements.Function can only work with Select statement.
Stored Procedure can run independently using Exec command.Function can't be run independently.
Print command is can be used in Stored Procedure.Print command is can't be used in Function.