Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Query on view doesn't work with where clause
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Yak Posting Veteran

98 Posts

Posted - 06/04/2014 :  13:00:54  Show Profile  Reply with Quote

I have a view that executes fine. It returns about a million records and executes in a couple seconds. The problem I am having is that if I query the view with a filter it executes very slowly. About a row per second - so it would take forever to complete.

This works fine...
SELECT     *
FROM         vw_AssemblyInquiry

But this does not...
SELECT     *
FROM         vw_AssemblyInquiry
WHERE     (Project = N'12-282')

In addition, if I add the filter directly to the view query then it will work fine. I just won't work if I append a filter to a SELECT against the view.

I hope this is clear enough. Does any understand what is happening?


Almighty SQL Goddess

38200 Posts

Posted - 06/04/2014 :  13:01:48  Show Profile  Visit tkizer's Homepage  Reply with Quote
Do you have an index on Project? Is it an indexed view?

Show us the execution plan of both queries.

Tara Kizer
SQL Server MVP since 2007
Go to Top of Page

Yak Posting Veteran

98 Posts

Posted - 06/09/2014 :  10:34:42  Show Profile  Reply with Quote
Sorry for the delay. This issue seemed to have resolved itself. For a couple days it would not work but now everything is working again. I do not manage the server so I don't know if there was something occurring in the background that would have caused this issue. Thanks for your help. I have double checked to ensure all of my indexes are in place.
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000