Of course it doesn't, because the PK of the table was changed. The value of user_id
column in inserted
pseudotable is different from the one in the UU
table. You need the value from deleted table to match the user_id
column, and everything else from inserted
. But the problem is that there is no way to match inserted
and deleted
tables any more, when the PK was changed. A mess.
If it's always a single-row update, you might get away with it, using a cross join between UU and inserted
and a `WHERE UU.user_id = (SELECT user_id from deleted)' in the update statement.
Mutch better -- disallow the PK update altogether. After all, it's not the same row any more if the PK's changed.