<p>One simple method I've used in the past is basically just creating a second table whose structure mirrors the one I want to audit, and then create an update/delete trigger on the main table.  Before a record is updated/deleted, the current state is saved to the audit table via the trigger.</p>

<p>While effective, the data in the audit table is not the most useful or simple to report off of.  I'm wondering if anyone has a better method for auditing data changes?</p>

<p>There shouldn't be too many updates of these records, but it is highly sensitive information, so it is important to the customer that all changes are audited and easily reported on.</p>

[{'answer_id': 3845, 'author': 'Mark Harrison', 'author_id': 116, 'author_profile': 'https://Stackoverflow.com/users/116', 'pm_score': 1, 'selected': False, 'text': '<p>Are there any built-in audit packages?  Oracle has a nice package, which will even send audit changes off to a separate server outside the access of any bad guy who is modifying the SQL.</p>\n\n<p>Their example is awesome... it shows how to alert on anybody modifying the audit tables.</p>\n'}, {'answer_id': 3848, 'author': 'Greg Hurlman', 'author_id': 35, 'author_profile': 'https://Stackoverflow.com/users/35', 'pm_score': 5, 'selected': True, 'text': "<p>How much writing vs. reading of this table(s) do you expect?</p>\n\n<p>I've used a single audit table, with columns for Table, Column, OldValue, NewValue, User, and ChangeDateTime - generic enough to work with any other changes in the DB, and while a LOT of data got written to that table, reports on that data were sparse enough that they could be run at low-use periods of the day.</p>\n\n<p><strong>Added:</strong>\nIf the amount of data vs. reporting is a concern, the audit table could be replicated to a read-only database server, allowing you to run reports whenever necessary without bogging down the master server from doing their work.</p>\n"}, {'answer_id': 3915, 'author': 'GateKiller', 'author_id': 383, 'author_profile': 'https://Stackoverflow.com/users/383', 'pm_score': 1, 'selected': False, 'text': '<p><a href="http://www.krell-software.com/omniaudit/" rel="nofollow noreferrer">OmniAudit</a> might be a good solution for you need.  I\'ve never used it before because I\'m quite happy writing my own audit routines, but it sounds good.</p>\n'}, {'answer_id': 3939, 'author': 'Chris Miller', 'author_id': 206, 'author_profile': 'https://Stackoverflow.com/users/206', 'pm_score': 1, 'selected': False, 'text': '<p>I use the approach described by Greg in his <a href="https://stackoverflow.com/questions/3823/suggestions-for-implementing-audit-tables-in-sql-server#3848">answer</a> and populate the audit table with a stored procedure called from the table triggers. </p>\n'}, {'answer_id': 37646, 'author': 'HadleyHope', 'author_id': 3416, 'author_profile': 'https://Stackoverflow.com/users/3416', 'pm_score': 2, 'selected': False, 'text': '<p>I have found these two links useful:</p>\n\n<p>Using CLR and single audit table.<br />\n<a href="http://web.archive.org/web/20090429064008/www.sqljunkies.ddj.com/Article/4CD01686-5178-490C-A90A-5AEEF5E35915.scuk" rel="nofollow noreferrer">Creating a generic audit trigger with SQL 2005 CLR</a></p>\n\n<p>Using triggers and separate audit table for each table being audited.<br />\n<a href="http://web.archive.org/web/20071006100909/http://sqlserver2000.databases.aspfaq.com:80/how-do-i-audit-changes-to-sql-server-data.html" rel="nofollow noreferrer">How do I audit changes to SQL Server data?</a></p>\n'}, {'answer_id': 16479360, 'author': 'John Emeres', 'author_id': 2141018, 'author_profile': 'https://Stackoverflow.com/users/2141018', 'pm_score': 3, 'selected': False, 'text': '<p>We are using two table design for this. </p>\n\n<p>One table is holding data about transaction (database, table name, schema, column, application that triggered transaction, host name for login that started transaction, date, number of affected rows and couple more). </p>\n\n<p>Second table is only used to store data changes so that we can undo changes if needed and report on old/new values. </p>\n\n<p>Another option is to use a third party tool for this such as <a href="http://www.apexsql.com/sql_tools_audit.aspx" rel="noreferrer">ApexSQL Audit</a> or Change Data Capture feature in SQL Server.</p>\n'}]
['https://Stackoverflow.com/questions/3823', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/423/']