diffrance between stored procedure & function in sql server?
Answer Posted / dev
Difference between function and stored proc:
========================================================
Stored Procedure :supports deffered name resoultion Example
while writing a stored procedure
that uses table named tabl1 and tabl2 etc..but actually not
exists in database is allowed
only in during creation but runtime throws errorFunction
wont support deffered name
resolution.
2. Stored procedure returns always integer value by default
zero. where as function return
type could be scalar or table or table values(SQL Server).
3. Stored Procedure is pre compiled exuction plan where as
functions are not.
4. Stored Procedure retuns more than one value at a time
while funtion returns only one
value at a time.
5. We can call the functions in sql statements (select max
(sal) from emp). where as sp is
not so
6. Function do not return the images,text whereas sp
returns all.
7. Function and sp both can return the values. But function
returns 1 value only.
procedure can return multiple values(max. 1024) we can
select the fields from function. in
the case of procdure we cannot select the fields.
8. Functions are used for computations where as procedures
can be used for performing
business logic
9. Functions MUST return a value, procedures need not be.
10. You can have DML(insert, update, delete) statements in
a function. But, you cannot call
such a function in a SQL query..eg: suppose, if u have a
function that is updating a table..
you can't call that function in any sql query.
- select myFunction(field) from sometable;
will throw error.
11. Function parameters are always IN, no OUT is possible
| Is This Answer Correct ? | 5 Yes | 0 No |
Post New Answer View All Answers
What is the use of response redirect in asp.net?
What is the file through which you can customize your asp.net application?
How to include silver light .xap page into asp.net web application and what is the purpose of using silverlight application?
if i wanna deploy my asp.net project to the production server and situation is that i m still not compiled my project i have as-is on my development side now on production server we dont have a visual studio now what kind of settings i need to be to do in webconfig /machine.config file to deploy my project and in iis too....
What are the Types of objects in ASP
How do I upload a file from my ASP.NET page?
How to do parallel database export in remote SQL Server in ESSL time track. It is working for local server but not working for remote SQL Server
What is State Management in .Net and how many ways are there to maintain a state in .Net? What is view state?
Which Is Faster MVC or ASP.net ?
What is ispostback method in asp.net? Why do we use that?
How response object is related to asp's response object?
How long should a session id be?
Differentiate between early binding and late binding.
What are the server controls in asp.net?
What are session state modes?