Hi all,
First, I'd like to explain my understanding of Views and SPs (which may or may not be right).
lets say we have a view "MyView" that is compiled like this:
It is my understanding that, when writing a simple select like this:
will execute the entire view SQL statement, then once the entire data set is returned to the view, return only those records where MyCol is greater than 2000.
now, it is also my understanding that you can also have a stored procedure with the same exact SQL that defines the view above, with the added ability to pass in a variable (2000) and incorporate it into the SP sql, which will effectively return the same data.
however, i feel like there are some cases where the SP is faster. Is it acceptable (by general standards and experts like you) to use an SP for this situation, even though the underlying premise of a SP is to perform transactions on data, rather than simply returning a data set?
I appreciate your time and comments.
Cory
*cLFlaVA
----------------------------
[tt]mr. pibb + red vines = crazy delicious![/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
First, I'd like to explain my understanding of Views and SPs (which may or may not be right).
lets say we have a view "MyView" that is compiled like this:
Code:
select <column listing>
from table1 join table2 ...
<several other joins>
It is my understanding that, when writing a simple select like this:
Code:
select * from MyView where MyCol > 2000
will execute the entire view SQL statement, then once the entire data set is returned to the view, return only those records where MyCol is greater than 2000.
now, it is also my understanding that you can also have a stored procedure with the same exact SQL that defines the view above, with the added ability to pass in a variable (2000) and incorporate it into the SP sql, which will effectively return the same data.
however, i feel like there are some cases where the SP is faster. Is it acceptable (by general standards and experts like you) to use an SP for this situation, even though the underlying premise of a SP is to perform transactions on data, rather than simply returning a data set?
I appreciate your time and comments.
Cory
*cLFlaVA
----------------------------
[tt]mr. pibb + red vines = crazy delicious![/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]