Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Views vs. Stored procedures

1,327 views
Skip to first unread message

et

unread,
Jan 17, 2006, 9:52:00 AM1/17/06
to
Are views faster than stored procedures if you're working with a complicated
select query with lots of joins, etc? Or is it just easier to maintain.
When should you use a view instead of a stored procedure?


Adam Machanic

unread,
Jan 17, 2006, 11:10:14 AM1/17/06
to
No, there is no performance difference.

You should use a view if you need to encapsulate a query that will be used
later to build other queries. You can JOIN to a view. You can't do
that--at least, as easily--with a stored procedure.


--
Adam Machanic
Pro SQL Server 2005, available now
http://www.apress.com/book/bookDisplay.html?bID=457
--


"et" <eaglete...@yahoo.com> wrote in message
news:usSiRW3G...@TK2MSFTNGP11.phx.gbl...

Hugo Kornelis

unread,
Jan 17, 2006, 3:55:48 PM1/17/06
to

Hi et,

They are very different things.

A stored procedure:
* accepts parameters
* can NOT be used as building block in a larger query
* can contain several statements, loops, IF ELSE, etc.
* can perform modifications to one or several tables
* can NOT be used as the target of an INSERT, UPDATE or DELETE
statement.

A view:
* does NOT accept parameters
* can be used as building block in a larger query
* can contain only one single SELECT query
* can NOT perform modifications to any table
* but can (sometimes) be used as the target of an INSERT, UPDATE or
DELETE statement.

Asking which is faster is like comparing the speed of a car with that of
a boat - the speed difference is irrelevant, since you'll always prefer
the boat if you travel over water, and always the car for travels over
land.

--
Hugo Kornelis, SQL Server MVP

et

unread,
Jan 18, 2006, 8:16:50 AM1/18/06
to
Thanks, everyone, this was very helpful, exactly what I needed.


"et" <eaglete...@yahoo.com> wrote in message
news:usSiRW3G...@TK2MSFTNGP11.phx.gbl...

gopalakr...@bigtree.in

unread,
Aug 23, 2015, 7:45:13 AM8/23/15
to
how to enter the subquery inside
the procedure
0 new messages