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
 SQL Server Development (2000)
 find logged in user

Author  Topic 

qwertyjjj
Posting Yak Master

131 Posts

Posted - 2008-02-04 : 11:39:26
We have a field in our table called LUser.
This is suposed to be updated by the calling application but not always.
Is it possible to add a trigger to update this with the login name?
How would I get the login name?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-02-04 : 12:10:48
Yup. You can do it. You can use SUSER_SNAME() funtion or SYSTEM_USER function to achieve this. I would suggest you to create a DEFAULT constraint on column to ppopulate this value rather than a trigger as performance using trigger will be really slow.
Go to Top of Page

qwertyjjj
Posting Yak Master

131 Posts

Posted - 2008-02-04 : 12:29:49
but the constraint will only work when inserting won't it?
Whereas a trigger everytime it is updated/deleted/inserted.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-02-04 : 12:47:17
That case you need an INSTEAD OF TRIGGER
Go to Top of Page
   

- Advertisement -