mercredi 9 août 2017

Add a field that read the last login user who makes update

I tried to add a field that read the last updated user but this field read the database user “azteca”, my need here is to write the user name who login to the web application.

How I can enhance the below code

ALTER TRIGGER [azteca].[tr_userupdat2]

ON [azteca].[REQUEST]

AFTER UPDATE

AS
SET NOCOUNT ON; IF TRIGGER_NESTLEVEL() > 1 RETURN;
   UPDATE [azteca].[REQUEST]
   SET 
     TEXT1=USER_NAME()
    FROM INSERTED i
   WHERE i.REQUESTID = REQUEST.REQUESTID




Aucun commentaire:

Enregistrer un commentaire