Saturday, June 12, 2010

Differences Between Stored Procedure and User Defined Function

The Differences Between a Stored Procedure and a User Defined Function are :

  1. User Defined Function Can be executable from SQL Select statement where as Stored Procedure cannot be executable from SQL select statement. We have to use execute Or Exec Keyword to run the Stored Procedure.
  2. Stored Procedure Supports Output Parameters where as User Defined Function does not Return Output Parameter.
  3. Stored Procedure Can’t return a Table variable while the User Defined Function Can.
  4. Stored Procedure Can’t Join to a stored Procedure while a user defined function can join to a UDF.
  5. Stored procedure can be used to change some of Server Environment & Operating Environment where as this is not possible in case of User Defined Function.
  6. T-SQL ignores the Errors and Processes next statement in case of stored Procedure But it stops the process in case of User Defined function.
  7. Stored Procedure can be used in XML for Clause while Used defined function cannot.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.