Chris Stevenson
NDCO MS Application Support
AT&T Wireless Services
chris.stevenson@a...
(xxx)xxx-xxxx
AT&T Wireless - Proprietary Information
Use Pursuant to Company Instructions.
-----Original Message-----
From: Stevenson, Chris
Sent: Friday, December 06, 2002 4:28 PM
To: 'sql_language@p...'
Subject: FW: Update Triggers Updating field with Current_user name
Hi
I have read through your archives and can't find help on this specific
topic. It seems like it should be easy but I can't get the following
trigger working.
I am trying to populate the LastUpdatedBy field with the username of the
user
who last updated the table.
CREATE TRIGGER [LastUpdatedBy] ON [dbo].[UAccts]
FOR UPDATE
AS
DECLARE @LUP varchar(50)
SET @LUP = convert(VARCHAR(50), CURRENT_USER)
IF ( (SUBSTRING(COLUMNS_UPDATED(),1,1)=power(2,(3-1))
+ power(2,(5-1)))
AND (SUBSTRING(COLUMNS_UPDATED(),2,1)=power(2,(1-1)))
)
UPDATE UAccts
SET LastUpdatedBy = @LUP
GO
Chris Stevenson