Given this query, how can I rewrite it to make it more indexable:
SELECT tableUID FROM MyTable
WHERE DateDiff(D, mydate, GETDAT()) BETWEEN 0 AND 29
--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200608/1Try this
SELECT tableUID FROM MyTable
WHERE mydate BETWEEN DATEADD(d,-29,GETDATE()) and GETDATE()
Denis the SQL Menace
http://sqlservercode.blogspot.com/
cbrichards via SQLMonster.com wrote:
> Given this query, how can I rewrite it to make it more indexable:
> SELECT tableUID FROM MyTable
> WHERE DateDiff(D, mydate, GETDAT()) BETWEEN 0 AND 29
> --
> Message posted via SQLMonster.com
> http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200608/1
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment