Louis Lam (9/27/2007)
Anyone know of any way in SQL Server that allow me to find record value before and after update value for auditing purpose. I know it can be done by witting trigger. But does SQL Server have some audit native way that can accomplish this? If the database is in Full log mode, would I be able to read the transaction redo log and get the before update value base on some transaction id?
There must be some way of doing this right? There are third party product that claim to be able to restore records on accidentally update or delete without restoring the whole database. So I assume they must have some way of reading the transaction log? Anyone have experience with doing this? Any help would be greatly appreciate?
the transaction log indeed contains the information about how data rows have changed. It contains full information for inserted and deleted rows, deltas for modified rows (if you modify only 2 bytes in a 100 byte long row, only the old two and the new two bytes will be recorded). The data is not recorded for table truncations and table drops. There are some operations like table splits, page movements that are more difficult to follow. Depends on how desperate you are, you can look at
dbcc log (dbid,-1) with tableresults
but these are difficult to understand if you have not spent working with transaction logs before. There are however third party tools. I've written one to 2000 (Log Rescue, this is free), Lumigent, Apex and Quest have a tool that works with 2005.
Andras Belokosztolszki, MCPD, PhD