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
what is a self join? : Sql server database administration
Characterize join and name diverse sorts of joins?
What is collation?
How do you rebuild an identity column?
What is read uncmmited?
What are the export options of ssrs?
what is normalization? : Sql server database administration
What is implicit cursors?
What is transactional replication?
Do you know what is recursion? Is it possible for a stored procedure to call itself or recursive stored procedure? How many levels of sp nesting is possible?
What is difference between delete and truncate commands?
Where do you find the default Index fill factor and how to change it?
How to transfer a table from one schema to another?
What are the recovery models for a database?
what is unique and xaml nonclustered index