delete a
from inserted i,db1.dbo.user1 a
where a.username=i.username
and i.rights not like '%right1%'
insert db1.dbo.user1
select * from inserted i
where i.rights like '%right1%'
and not exists (
select * from db1.dbo.user1 a
where a.username=i.username
)