Suggestions for implementing audit tables in SQL Server?

后端 未结 6 2154
春和景丽
春和景丽 2020-12-01 09:33

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

6条回答
  •  春和景丽
    2020-12-01 10:02

    How much writing vs. reading of this table(s) do you expect?

    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.

    Added: If 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.

提交回复
热议问题