SQLDependency — Invalid SQL

↘锁芯ラ 提交于 2019-12-23 20:15:09

问题


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] 

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?


回答1:


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.



来源:https://stackoverflow.com/questions/12479473/sqldependency-invalid-sql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!