I want to know the difference in the case of SQL Server
Answers
Abhi
On 2006-08-04 23:34:20
procedures return many values while function can return only one.this is wrt VHDL
hoverX
On 2006-08-04 23:32:38
From my experience procedure is most commonly used to describe a 'stored procedure' in a database. Which basically is a sql query stored on the db so it can be called easily in the future, by either an application or a user.
A function is a portion of code within a larger program which serves a single purpose. for example, you could write a function to calculate the area of a circle. Then, any time in your code when you want to calculate the area of a circle you could use that function instead of writing that code over again each time.
Some programming languages also use the term procedure to denote a function that does not return a value.
frappe179
On 2006-08-05 01:03:13
Definition:
The terms procedure & function are used interchangeably in most Scheme discussion. On occasion, however, they are distinguished in meaning: functions are really mathematical relations that map every input to exactly one output; procedures are recipes for computation that perform side effects
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'll also find that although a SPROC can be used in an XML FOR clause, a UDF cannot be.
If you have an operation such as a query with a FROM clause that requires a rowset be drawn from a table or set of tables, then a function will be your appropriate choice. However, when you want to use that same rowset in your application the better choice would be a stored procedure.
There's quite a bit of debate about the performance benefits of UDFs vs. SPROCs. You might be tempted to believe that stored procedures add more overhead to your server than a UDF. Depending upon how your write your code and the type of data you're processing, this might not be the case. It's always a good idea to text your data in important or time-consuming operations by trying both types of methods on them.
masku darling
On 2006-08-04 23:49:23
depends on the context that is the language and/or technology u r talking about. In C/C++ procedure and functions are same. In .NET procedures don't return value but functions do.
In java there is nothing like procedures.
In database procedures are stored compiled queries and functions are in-built piece of expressions that u can use to build ur queries.
shavin
On 2006-08-04 23:27:15
A procedure do not return a value its just a block of code that gets executed when called
A function returns you a value which is used in your program rest same as procedure
Answers
Abhi
On 2006-08-04 23:34:20
hoverX
On 2006-08-04 23:32:38
frappe179
On 2006-08-05 01:03:13
masku darling
On 2006-08-04 23:49:23
shavin
On 2006-08-04 23:27:15