Here's the trigger:
IF EXISTS (SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID('dbo.trg_Update_SLAMetric'))
DROP TRIGGER dbo.trg_Update_SLAMetric
go
CREATE TRIGGER trg_Update_SLAMetric
ON dbo.SLAMetric
AFTER UPDATE
AS
-- Update UpdateDate , LastUpdatedBy
UPDATE SLAMetric
SET
UpdateDate = GETDATE()
,LastUpdatedBy =
case
When UPDATE(LastUpdatedBy) then Inserted.LastUpdatedBy
else SUSER_NAME()
end
from dbo.SLAMetric SLAMetric
join Inserted
on Inserted.SLAMetricID = SLAMetric.SLAMetricID
It correctly updates the LastUpdatedBy field in both situations - updating the table and including the LastUpdatedBy field, and also just updating other fields (in which case it's just set to SUSER_NAME().
update slametric set MetricNumerator = 0
select * from slametric
update slametric set LastUpdatedBy = 'test'
select * from slametric