Domanda

I need to have two SQL dependencies on the same table as I have to monitor them for different reasons.

So I wrote the following two queries -

**SELECT [ID], [COLUMN1] FROM DBO.TABLENAME WHERE SOMECOLUMN = VAL1 ORDER BY ID**

**SELECT [ID], [COLUMN2] FROM DBO.TABLENAME WHERE SOMECOLUMN = VAL1 ORDER BY ID**

Earlier we were using only the first query, and second query was added later. They are both used to create two separate dependencies.

But what I am observing is that when I update COLUMN2, I expect only callback registered with second query to get fired. Instead BOTH callbacks ( callback registered with first query and the second query) are getting fired.

Can someone help me out?

Thanks in advance.

È stato utile?

Soluzione

The differentiation between columns projected vs. columns updated has long been a problem with query notifications. Unfortunately things are as they are, so you will get false positives (notifications when nothing changed). See Understanding When Query Notifications Occur:

Notice that SQL Server may produce a query notification in response to events that do not change the data, or in response to a change that does not actually affect the results of the query. For example, when an UPDATE statement changes one of the rows returned by the query, the notification may fire even if the update to the row did not change the columns in the query results.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top