问题
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