Wrox Home  
Search P2P Archive for: Go

  Return to Index  

sql_language thread: FW: Update Triggers Updating field with Current_user name


Message #1 by "Stevenson, Chris" <chris.stevenson@a...> on Fri, 6 Dec 2002 17:38:44 -0800
 

 

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

 



  Return to Index