Question

Here is a description in MSDN of the indexed view:"As modifications are made to the data in the base tables, the data modifications are reflected in the data stored in the indexed view".

But i'm confused now, will updating any field in base table cause the auto maintain of the indexed view, even this field isn't included in the definition of the the indexed view?

Thanks!

Était-ce utile?

La solution

It's not documented, but I believe that some activity will occur.

From various hints in the documentation, I believe that SQL Server actually constructs something quite like a trigger on each base table. So the "trigger" will run for every update/insert/delete action on the table.

However, I believe that the trigger uses something like COLUMNS_UPDATED to check which columns have had actual update activity, and will exit early if no relevant columns were affected.

E.g. if you sent ANSI_NULLS to OFF (ON is required by indexed views), then any updates against columns not used by the view will work. Whereas any updates that mention a column used in the view (even if the SET is a no-op, e.g. Column1 = Column1), then you'll get an error message.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top