SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


audit data change, before and updated value


audit data change, before and updated value

Author
Message
Louis Lam-391748
Louis Lam-391748
SSC Rookie
SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)

Group: General Forum Members
Points: 30 Visits: 75
Hi all,



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?



Thanks,

Louis.
Andras Belokosztolszki
Andras Belokosztolszki
SSCrazy
SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)

Group: General Forum Members
Points: 2339 Visits: 1585
Louis Lam (9/27/2007)
Hi all,







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?







Thanks,



Louis.




Hi Luis,



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.



Regards,

Andras



Andras Belokosztolszki, MCPD, PhD
GoldenGate Software
Louis Lam-391748
Louis Lam-391748
SSC Rookie
SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)

Group: General Forum Members
Points: 30 Visits: 75
Hi Andras,



Thank you for the information. This is very helpfull Smile I did a simple test using this query



update test set col1 = 'hello again2'



Then I ran dbcc log (11, -1) with tableresults I got 3 three new rows, out of which I beleive this one is pertain to my transaction. Do you know where I can get information on interpreting these result. In particular, there are some column name begin with rowlog contents, I believe these must be the content of my update. But it is in some hex value, I guest? Any way to convert this to format like varchar?



Thanks.





00000015:0000019d:0003 LOP_MODIFY_ROW LCX_HEAP 0000:0000026c 0x0000 62 124 00000015:0000019d:0001 0x0200 72057594042318848 dbo.test 0001:00000098 0 00000015:0000005e:0002 72057594038321152 65 4 9 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 3 ACQUIRE_LOCK_IX OBJECT: 11:2073058421:0 ;ACQUIRE_LOCK_IX PAGE: 11:1:152;ACQUIRE_LOCK_X RID: 11:1:152:0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 0x160068656C6C6F20616761696E 0x170068656C6C6F20616761696E32 0x 0x0101000C0000755C907B00000102000402030004 NULL 0x00003E00150000009D010000010002006C02000000000401980000000100000043000000150000005E00000002000001000006000000000109000D00410004000D000E0000001400160068656C6C6F20616761696E010000170068656C6C6F20616761696E3200000101000C0000755C907B00000102000402030004
Benjamin Nelson
Benjamin Nelson
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
Points: 1 Visits: 2
If you're still looking to reconstruct the data row from that Hex string, check this document out ... particularly page 40.

http://www.sans.org/reading_room/whitepapers/application/1906.php
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search