开发者

Why would a t-sql query that was previously working and hasn't been changed, no longer return any rows?

I have run this query successfully multiple times no more than a couple of weeks ago. I have not made a single change to it. It seems unlikely that the back-end data would have changed enough to produce no res开发者_JAVA百科ults. What else could contribute to this?


If it's the exact same query, then it has to be either the data or the database that is being queried that have changed unless you have some sort of temporal/transient filtering in your query, such as filtering on a date range with GETDATE.

So I'd check the following things in order:

  1. It's the exact same query?
  2. Running on the same database?
  3. Does the query filter on time-sensitive data?
  4. Otherwise, I'm guessing the data has changed


to add to @Daniel DiPaolo's excellent answer, if you use a view within your query, it might have changed. And as a real stretch, if you have computed columns that you join or filter on, and the formula has changed, that might cause the rows to not be returned.


try to recompile the query. the easiest way is to drop and recreate it.

if the query runs now, then a bad queryplan is the cause. this happened in my db. the solution was to add a recompile hint. sounds very bad i know...

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜