Search code examples
sql-serversql-server-2014-express

trigger returns dbo instead of sa


Why does USER_NAME(USER_ID()) returns dbo and not 'sa' as the current username ?

I have a trigger that is supposed to insert the username of the user making changes to the table.

However the trigger inserts dbo as the user. Why is this?


Solution

  • Start using suser_sname()

    and STOP using the sa login!!