This should get you started:
Code:
CREATE TRIGGER tr_DaTable ON dbo.DaTable
AFTER UPDATE AS
BEGIN
DECLARE @UserID integer
-- SELECT @UserID = [Security].[User].[IDUser]
-- FROM [Security].[User]
-- INNER JOIN sys.sysprocesses ON
-- [Security].[User].[Username] = sys.sysprocesses.NT_UserName
-- WHERE spid = @@SPID
SELECT @UserID = uid --,NT_UserName, LogiName
from sys.sysprocesses
where spid = @@SPID
UPDATE U
SET LastUpdateBy = @UserID,
LastUpdateTime = GetDate()
FROM DaTable U
INNER JOIN inserted i ON
U.Id = i.Id
END
You should uncomment the first @UserID assignment.
Play a bit with
SELECT uid , NT_UserName, LogiName
from sys.sysprocesses
where spid = @@SPID
to find out what column you need.
I have played a little bit with PostgreSQL. I found the trigger syntax unlike anything I was familiar with (Informix, DB2, MSSQL). Thank you for this example.