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 1nf 2nf?
Explain about builtinadministrator?
What are the 10 characteristics of data quality?
How to declare a cursor with "declare ... Cursor" in ms sql server?
What is a full text index?
Suppose you want to implement the many-to-many relationships while designing tables. How would you do it?
Explain the dirty pages?
How do you send email on SQL Server?
What method is used by the Command classes to execute SQL statements that return single values?
What xml support does the sql server extend?
What is constraints and its types?
What is a filestream?
how can a database be repaired? : Sql server administration
How can you find out how many rows returned in a cursor?
Mention the differences between substr and charindex in sql server.