Trigger or Change Notification on SQL Server view
We have following scenario:
create table User {Id bigint, UserName nvarchar(5开发者_JAVA技巧0), GroupId bigint};
create table Group {Id bigint, GroupName nvarchar(50)};
create view UserView as
SELECT u.Id, u.UserName, g.GroupName
from User u
inner join Group g on u.GroupId = g.Id
Now I'd like to create one trigger on the view which is fired if the User table is updated or/and if the group table is updated.
Is this possible somehow using T-SQL?
Using INSTEAD OF triggers doesn't work because they are fired only if you perform updates directly to the view.
Thanks.
No, this is not possible. You'll have to define your triggers on the tables that are involved in the view in order to process changes.
精彩评论