开发者

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

开发者 https://www.devze.com 2022-12-26 23:33 出处:网络
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 produ

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

精彩评论

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

关注公众号