Monday, March 19, 2012

Applying criteria at the start of a series of views

I have a series of views that provide a final result set e.g view 5 is select
... from view4; View 4 is select ... from view3 etc.
That all works fine, but what this does is include all of the data from
whatever tables are involved even though I need a subset. My typical
scenario is that the majority of the data are in the table(s) involved in the
initial view(s)
What I would like to do is pass the necessary parameters to the view(s)
involved so as to limit the amount of data that gets passed along. I'm still
learning the right way to do things in SQL, so I appreciate any insights that
anyone can provide.
TIA,
John
"DevalilaJohn" <DevalilaJohn@.discussions.microsoft.com> wrote in message
news:098BB47D-453F-4B0A-A2E2-B843B10F30AA@.microsoft.com...
>I have a series of views that provide a final result set e.g view 5 is
>select
> ... from view4; View 4 is select ... from view3 etc.
> That all works fine, but what this does is include all of the data from
> whatever tables are involved even though I need a subset. My typical
> scenario is that the majority of the data are in the table(s) involved in
> the
> initial view(s)
> What I would like to do is pass the necessary parameters to the view(s)
> involved so as to limit the amount of data that gets passed along. I'm
> still
> learning the right way to do things in SQL, so I appreciate any insights
> that
> anyone can provide.
>
SQL Server will pass where-clause predicates down through views to the base
tables if it can. If the column in a view is the result of an expression,
however, this won't work.
David

No comments:

Post a Comment