Wednesday, March 7, 2012

Please help: Views and INSTEAD OF UPDATE trigger

Hi:

Currently I have two tables T1 and T2. A view V1 is defined over T1 with an INSTEAD OF UPDATE trigger and another view V2 is defined over V1 and T2 with another INSTEAD OF UPDATE trigger. Unfortunately, inside V2s trigger following update statement is not working:
Update V1 set V1.name = i.name from inserted i
because SQL server complains:
View 'V1' has an INSTEAD OF UPDATE trigger and cannot be a target of an UPDATE FROM statement.
Is there any way to get around this problem? I.e., how can I make the INSTEAD OF UPDATE trigger in V2 to work if I cant reference inserted?

Your help is appreciated,

JeffI think the problem is not with your "inserted" table, but with the target of the insert (View V1).

Modify your INSTEAD OF triggers so that they reference the underlying tables directly, rather than through secondary views.

No comments:

Post a Comment