What is the difference between Stored Procedure (SP) and User Defined Function (UDF)?

Q

What is the difference between Stored Procedure (SP) and User Defined Function (UDF)?

✍: Guest

A

Following are some major differences between a stored procedure and user defined functions:
UDF can be executed using the ďSELECTĒ clause while SPís can not be.
UDF can not be used in XML FOR clause but SPís can be used.
UDF does not return output parameters while SPís return output parameters.
If there is an error in UDF its stops executing. But in SPís it just ignores the error and moves to the next statement.
UDF can not make permanent changes to server environments while SPís can change some of the server environment.

2007-10-25, 4855👍, 0💬