Is there a way to find out which records have changed in an indexed view?

116 views Asked by At

I have a table (invoice details) which has two columns (productid and quantity). I created an indexed view on this table in order to know the balance of products.

When a user enters an invoice on a computer, I want to refresh the product balance on another computer, so I need to know which rows in the indexed view were changed.

2

There are 2 answers

0
David Browne - Microsoft On BEST ANSWER

Transactional Replication allows you to replicate Indexed Views as Tables. This will track changes to the indexed view and apply them to the subscribers, who have a copy of the indexed view data as a table in the subscriber database.

1
TomTom On

There is no way. You pull (regularly) and update. Any application that needs to distribute data updates that I have ever seen does not do it by updating from SQL Server, but does so by sending updates on their own data feeds implemented by an application server - mostly stock trading applications.

SQL Server has no functionality for this, nor does pretty much every db access layer I have ever seen. You repull and update the in client representation, either regularly (every X seconds) or when the user presses an update button.