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

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Modify WHERE clause to use index

Author  Topic 

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-02-09 : 20:09:22
My brain isn't working right now due to a lot of stress. Could someone help me rewrite this bit so that it can use an index?

WHERE DATEDIFF(dd, q.CREATION_TIME, i.CREATION_TIME) > 3

I just need to isolate q.CREATION_TIME to the left side of the WHERE clause. The table associated with the "i" alias will only contain one row, so I don't care about an index there.

WHERE q.CREATION_TIME ...

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-02-09 : 20:28:23

Looks like you are working too much

Try this:
 
WHERE q.CREATION_TIME < DATEADD(dd,-3,i.CREATION_TIME)
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-02-09 : 20:38:12
Thank you very much! I wish it was too much work causing me stress.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -