Difference between Store Procedure and UDF User Define
In this blog I am trying to differentiates between Store
Procedure and UDF User Define Function:
Stored procedure may or not return values.
It will allow DQL select statements as well as
DML statements such as insert, update, delete etc.
Stored procedures have mutually input and output
We can use try and catch blocks for exception
handling in stored procedures.
Stored procedure can use transactions inside stored
Stored procedure can use both table variables as
well as temporary table in it.
Stored Procedures be able to call functions.
Procedures can’t be called from
Select/Where/Having etc statements. Execute/Exec statement can be used to
call/execute stored procedure.
Store procedures can’t be used in Join clause.
User Define Function:
Function necessities return a value.
UDF will allow only Select statement; it will
not allow us to use DML statements.
UDF will allow only input parameters, doesn’t
support output parameters.
UDF will not allow us to use try-catch blocks.
UDF transactions are not allowed within
We can use only table variables; UDF will not
allow using temporary tables.
Stored procedures can’t be called from function.
Functions can be called from select statement.
can be used in join clause as a result set.