问题描述
最好的我可以告诉这里 ,我没有违反任何规则与此查询,但变化事件触发不断地与无效状态。
Best I can tell from here, I am not breaking any rules with this query, but the change event fires constantly with an invalid status.
SELECT
COUNT_BIG([PK_Column]) AS RecordCount
FROM
[dbo].[My_Table]
GROUP BY
Varchar_50_Column
如果我这样做,一切正常。
If I do this, everything works correctly.
SELECT
[PK_Column]
FROM
[dbo].[My_Table]
不过,我不想回这么多的数据,以及的SqlDependency似乎需要以后每次执行查询,一旦更改事件触发设置(或复位)认购。
However, I don't want to return this much data, and SqlDependency seems to require executing the query once after each time the change event fires to set up (or reset) the subscription.
任何想法的缺陷是在我第一次查询是什么?
Any idea what the flaw is in my first query?
推荐答案
看一看的如果您使用的GROUP BY子句,你将不得不使用 COUNT_BIG(*)
。在 social.msdn 我发现有一个类似/同样的问题,其他用户 - 这种说法解决它
Have a look at special considerations on query notifications If you make use of a group by clause you will have to use COUNT_BIG(*)
. On social.msdn I found another user having a similar / same problem - solving it with this statement.
这篇关于的SqlDependency - 无效的SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!