What are the differences between stored procedure and
functions in SQL Server 2000?

Answer Posted / aashish

In many instances you can accomplish the same task using either a stored procedure or a function. Both functions and stored procedures can be custom defined and part of any application. Functions, on the other hand, are designed to send their output to a query or T-SQL statement. For example, User Defined Functions (UDFs) can run an executable file from SQL SELECT or an action query, while Stored Procedures (SPROC) use EXECUTE or EXEC to run. Both are instantiated using CREATE FUNCTION.

To decide between using one of the two, keep in mind the fundamental difference between them: stored procedures are designed to return its output to the application. A UDF returns table variables, while a SPROC can't return a table variable although it can create a table. Another significant difference between them is that UDFs can't change the server environment or your operating system environment, while a SPROC can. Operationally, when T-SQL encounters an error the function stops, while T-SQL will ignore an error in a SPROC and proceed to the next statement in your code (provided you've included error handling support). You

Is This Answer Correct ?    7 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Does partitioning help performance?

531


What objects does the fn_my_permissions function reports on? : sql server security

563


If you lose rights to your sql server instance what are the options to connect to sql server instance? : sql server security

539


How can we delete Duplicate row in table?

636


How to attach adventureworkslt physical files to the server?

638






What is Lock table in SQL?

1006


What is a matrix in ssrs?

101


Where cross join is used?

519


What are number line correlation administrators will use while working with a subquery?

629


What is query optimization process?

522


How many full-text indexes can a table have?

555


What are the advantages to use stored procedures?

573


Do you know the capabilities of cursors?

535


Mention the uses of stored procedures.

574


What is difference between stored procedure and user defined function?

553