SQL 2005 database - Trigger to return user name on network when using sa logon to database
Posted on 2013-05-26
I have an application updating a MSSQL 2005 database and would like to record the change to one field on a table. I have the trigger working fine to record this and can return all info I need except I would like to return the name of the user logged in on the network.
I have used USER_NAME - returns dbo and SYSTEM_USER - returns sa.
HOST_NAME() returns the Computer name which is useful.
I can get the @@SPID and lookup the relavent info from the session - sysprocesses - there is a field nt_user_name but this is blank and I cannot see anything that gives the logged on user.
Appreciate any help in identifying how I could access this.