all groups > sql server programming > april 2004 >
You're in the

sql server programming

group:

difference between function & stored procedure


difference between function & stored procedure beginner sql user
4/29/2004 11:21:03 PM
sql server programming:
Hi All

Please tell me difference between function & stored procedure. Also we can use views instead of procedure to get result of select. Then where to use procedure and where view

Please help

Re: difference between function & stored procedure user
4/30/2004 1:16:02 AM
Hi Steve

Thanks a lot for the help

You have explained well. I would have been more happy you had given difference from uses point (what to use and when to use) of view and not technically.

Is there any document avaible for the same

Thanks again
Re: difference between function & stored procedure user
4/30/2004 1:21:04 AM

hi

this is a very absrtact overview of what I think. If possible, can you please point out correct and wrong assumtions

Us
1) function: when you want to return a scalar value like if "can user update this record". thus you can have a your bussiness logic here

2) procedure: use for insert/update/delete/etc opertaions on database

3) views: use to get results from database. Thus user(programmers) well not have to concentrate on comlexity of database structure

Re: difference between function & stored procedure Steve Kass
4/30/2004 3:25:29 AM
Suppose V is a view, P is a stored procedure, and F() is a function that
accepts one integer argument.

Procedures are different from the others in this way:
You can write
select * from V
and
select * from F(1)

You cannot write
select * from P

You can not return custom messages for error conditions evaluating a
view or function, but you can return custom errors from procedures


Functions are different from the others in this way
You can write F() to define a table that can't be written as a single
select statement
You can write P to return a table that can't be written as a single
select statement



Views are different from the others in this way
You can put instead of triggers on views and can materialize views
through the user of indexes (under some conditions)

There are also other differences. When to use which depends on what you
want to do. There are no foolproof rules to follow.

Steve Kass
Drew University

[quoted text, click to view]
Re: difference between function & stored procedure Uri Dimant
5/2/2004 10:13:40 AM
Hi
One more and I think most important difference is that UDF are reformed much
similar as cursors work , row by row process and not like stored procedures
which works as set baced data. If you have very large set data you probably
will t want to avoid using UDF because the performance would very well
become a problem.



[quoted text, click to view]

AddThis Social Bookmark Button