Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

T-Sql view with addition where clause

Status
Not open for further replies.

kaiso

Programmer
Feb 7, 2001
12
US

I have created a view which consists of 4 tables with a 'where clause' and an 'order by' statement.

If I then call this view and add an additional restriction -- such as 'where {datefield} = today', will the database generate the full record set with all possible dates before saying - hey I only need to find data dated today??

All help appreciated.
 
Kaiso,

I think it's more like "record 1 from my view, are you in?"

Y/N

Next....

So, yeah, it constructs the entire view first. That's what you're asking for.

Have you indexed the view or the columns that underlie the view? I suspect you're having performance problems, right?

Run it through QA with the Execution Plan turned on, and see what you can do with it.

HTH,
PH
 
Imagine a view as a temporary table that is created everytime the query is run.

So, by your query, first a temp table is created with all the requested information from the four permanent tables, then the last WHERE is run against the temp table.


-SQLBill
 
And with SQL2000 it's possible to index your views, so you should (if you use 2K) see a performance improvement.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top