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] beginner sql user wrote:
>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.
>
>Thanks
>
>
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] "user" <anonymous@discussions.microsoft.com> wrote in message
news:670E4D11-0B4A-4528-AA6C-C99875A68ECF@microsoft.com...
>
> hi,
>
> this is a very absrtact overview of what I think. If possible, can you
please point out correct and wrong assumtions.
>
> Use
> 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.
>
>
>