开发者

SQL query returns nothing after minute

I'm trying to filter my data using dates in the WHERE clause to get a good idea of when stuff happened. However, when I run the query I get no results and the query takes about a minute to fully complete.开发者_开发技巧 Any help is always greatly appreciated.

Declare @date datetime

set @date = getdate() - 11

Select ColumnA,ColumnB
From TableA
Where DateCreated >= @date And DateCreated < GetDate()


You don't have any records in your table that fall into that date range.

or...

DateCreated isn't a datetime field.

It takes a minute likely because you don't have an index on that field and SQL is running a table scan to check every record.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜