The most important difference between Sql Stored Procedure and User Defined Functions
This article explains the most important difference between sql stored procedure and user defined functions in simple way.
STORED PROCEDURE
USER DEFINED FUNCTIONS
IT IS PRECOMPILED OBJECTS WHICH IS COMPILED FOR FIRST TIME AND AFTER THAT IT IS READY TO REUSE
FUNCTION IS COMPILED AND EXECUTED EVERY TIME, WHENEVER IT IS CALLED.
IT DOES NOT HAVE RETURN TYPE,BUT RETURNS VALUES THROUGH OUT PARAMETER.
A FUNCTION HAS RETURN TYPE AND IT RETURNS A VALUE.
YOU CAN USE DML STATEMENTS SUCH AS INSERT,UPDATE ,SELECT AND DELETE WITHIN STORED PROCEDURE
ONLY SELECT STATEMENT IS ALLOWED IN USER DEFINED FUNCTIONS
YOU CAN CALL FUNCTION FROM THE STORED PROCEDURE
YOU CANNOT CALL STORED PROCEDURE INSIDE THE FUNCTION
YOU CANNOT CALL PROCEDURE USING SELECT STATEMENT
YOU CAN CALL FUNCTION USING SELECT STATEMENT