Search code examples
sql-servertriggersaudit

How to tell what computer a query came from in a trigger


I created a trigger for auditing purposes that logs changes made to a particular table.

Is there any way for me to tell what computer the query that set the trigger off came from? I have full access to the database, but no access to software code.


Solution

  • I'd include these in your auditing:

    SELECT 
        HOST_NAME()  ModifiedByHost, 
        SYSTEM_USER  ModifiedByUser,
        APP_NAME()  ModifiedByAppName
    

    HOST_NAME() will give you the computer.

    http://technet.microsoft.com/en-us/library/ms178598.aspx