Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Trigger

Author  Topic 

TSQLMan
Posting Yak Master

160 Posts

Posted - 2003-09-10 : 17:19:15
I wrote a trigger for update, on a table.(Very small number of transactions.) How can I pull the NT_UserName. Here is what I have now. I can add a field to the audit table.

CREATE TRIGGER _TR_ANALYSIS_HISTORY

ON ANALYSIS_HISTORY

FOR UPDATE

AS

IF(COLUMNS_UPDATED()& 19) > 0

BEGIN INSERT INTO ANALYSISAUDIT
(LOADED,RECEIVED,BARGE,DESTINATION,TONS,SAMPLE,MOISTURE, ASHAR,ASHDB,SULAR,SULDB,
BTUAR,BTUDB,MAF,ABSO2,LBASH,SHIPTYPE,MOREID)

SELECT LOADED,GETDATE(),BARGE,DESTINATION,TONS,"SAMPLE",MOISTURE, ASH_AR,ASH_DB,
SUL_AR,SUL_DB,BTU_AR,BTU_DB,MAF,LB_S02,LB_ASJ,SHIP_TYPE,MORE_ID
FROM DELETED


END

simondeutsch
Aged Yak Warrior

547 Posts

Posted - 2003-09-10 : 17:28:18
Check out the suser_name and suser_sname system functions.

Sarah Berger MCSD
Go to Top of Page

TSQLMan
Posting Yak Master

160 Posts

Posted - 2003-09-11 : 10:30:08
Worked like a champ, Thanks.
Go to Top of Page
   

- Advertisement -