Starting or changing a notification in a SQL Server view

We have the following scenario:

create table User {Id bigint, UserName nvarchar(50), 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 would like to create one trigger in the view, which runs if the User table or / is updated, and if the group table is updated.

Is it possible to use T-SQL somehow?

Using INSTEAD OF triggers does not work, because they are triggered only when the updates are directly executed.

Thank.

+3
source share
1 answer

No, It is Immpossible. You will need to define your triggers in the tables that participate in the view in order to process the changes.

+3
source

Source: https://habr.com/ru/post/1791240/


All Articles