I create a indexed view View1
on Table1
and Table2
and have instead of trigger and after trigger on Table1
that use of View1
. It seem that data of View1
not change when I use this view on instead of trigger and after trigger. But I want to use View1
with new data when use this view on after trigger. How can I do it. It should be noted that I use with Noexpand
hint when use indexed view (when don't use with noexpand
hint in SQL Server 2008 R2
act this indexed view such as no indexed view).
The indexed view is updated after all triggers on the base tables are executed. You can see that in the query plan. There will be only one clustered index update on the view.
However, you can create INSTEAD OF
triggers on the view and then make all your operations on the indexed view. However,there are some restrictions when updating/inserting/deleting through an updateable view. You can read about them here.
Note that views allow only INSTEAD OF
triggers, not AFTER
too.
The most important thing to know about updating indexed views is that any modifications, including UPDATE, INSERT, and DELETE statements, must reference columns from only one base table.