May 2, 2008 at 6:38 am
There are several differences, but (arguably) the most important difference is that a function is designed to return something other than just an error code.
April 20, 2011 at 11:42 pm
you can visit this link also
http://dotnetpeoples.blogspot.com/2011/04/stored-procedure-vs-user-defined.html
April 22, 2011 at 8:24 am
AShehzad (5/2/2008)
what is difference between stored procedure and user defined functions
There are so many, and they are so situation-specific, that this open-ended question goes WAY beyond what a forum post is truly for.
Best,
Kevin G. Boles
SQL Server Consultant
SQL MVP 2007-2012
TheSQLGuru on googles mail service
April 22, 2011 at 10:51 am
It sounds like an interview or homework question but I'll cough up what I believe are the most important...
A Table Valued Function can be used in the FROM of a query where the output of a stored procedure is much more difficult to use in a FROM clause.
UDF's cannot use Temp Tables.
UDF's cannot modify data in tables except for Table Variables.
UDF's cannot use dynamic SQL.
UDF's can't call other stored proceduresexcept for extended stored procedures.
UDF's cannot return any rows to the screen.
The only way for UDF's to use defaults for parameters is to pass the word DEFAULT to the parameter. They can simply be left out in a stored proc when defaults are assigned within the sproc.
UDF's cannot use indeterminate functions such as NEWID() (although there is a work around for that).
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply