Custom Auditing with Triggers and User Tables

  • I have a small dilemma and hopefully someone can give me some insight.

    I have to create auditing triggers to capture events on tables happening within my application.  Normally this is no problem with the SYSTEM_USER variable but we now have a custom user table with one SQL Server Service account, so essentially everything will look like the service account is performing all the actions.

    How can I pass that user or store the user name somewhere and access it from a trigger to insert into my log table?

    Chris

  • One method I've seen is to have a column in each table that holds the name/id of the user making the update/insert.  Then that column will be available to you in the trigger.

    Of course this would require that your application be modified to capture the username and update this new column so it would be available to your triggers.

     

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply