Paresh J
Paresh J

Reputation: 2419

Why are AFTER triggers not supported for views?

Can any one explain in detail with an example if possible, why AFTER triggers are not supported for views in SQL Server?

I know we use AFTER triggers after insert, update or delete on a table, then why not on a view, too?

Upvotes: 0

Views: 602

Answers (1)

Patrick Hofman
Patrick Hofman

Reputation: 157048

Because it is only possible to do something instead of an DDL statement on a view.

Views themselves don't contain data, so it is not possible to do something before or after a change since it can't be sure how one change on the view affects the data below it.

Example:

If you have a view resulting in one row, and you update that row, that row might disappear, 'another' row might pop up, and there is no way to tell the relation between the first and the last.

Upvotes: 5

Related Questions