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...
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" <eaglete...@yahoo.com> wrote in message
news:usSiRW3G...@TK2MSFTNGP11.phx.gbl...