Search code examples
sqldependency

SqlDependency, how does it work?


Using SqlDependency, we no need to use a timer to check if data is changed.

However how does it work? If the data changed, the sql server notify us, right?

If we have a query related to 2 tables: TabA and TabB in a database which contains 100 tables. When the data in TabA or TabB is changed, the sql server notify us. However if the data in TabC is changed, will the sql server notify us?


Solution

  • I don't think you will get notified of changes to TabC.

    Quote from Detecting Changes with SqlDependency (ADO.NET)

    A SqlDependency object can be associated with a SqlCommand in order to detect when query results differ from those originally retrieved.