SYS. fn_dblog returns the activity content of the current database log.
Use Db1
Go
If Exists ( Select 1 From SYS. Tables Where Name = ' T ' )
Drop Table T
Go
Create Table T (COL Int )
Go
DBCC Traceon ( 3505 , - 1 ) --- Disable automatic checkpoint behaviorhttp: // support.microsoft.com/kb/815436/en-us
Go
Checkpoint
Go
Select [ Current lsn ] , [ Previous lsn ] , [ Previous Page lsn ] , Partitionid, operation, context, [ Transaction ID ] , [ Log Record Fixed Length ] , [ Log Record Length ] From SYS. fn_dblog ( Null , Null )
Go
Insert Into T Values ( 1 ) --
Go
Select [ Current lsn ] , [ Previous lsn ] , [ Previous Page lsn ] , Partitionid, operation, context, [ Transaction ID ] , [ Log Record Fixed Length ] , [ Log Record Length ] From SYS. fn_dblog ( Null , Null )- - SQL Server need To Allocate Space For The new Table
Go
Checkpoint
Go
Insert Into T Values ( 1 )- -
Go
Select [ Current lsn ] , [ Previous lsn ] , [ Previous Page lsn ] , Partitionid, operation, context, [ Transaction ID ] , [ Log Record Fixed Length ] , [ Log Record Length ] From SYS. fn_dblog ( Null , Null )- - Only Insert Operation
Copy code
Http://support.microsoft.com/kb/815436/en-us
How to parse the 2008 operation log, especially the lop_modify_row operation? Different from lop_insert_rows lop_delete_rows
The insert, udpate, and delte operations of the database are recorded in the log,
For insert operations, after image is generated, that is, the result after the change,
For Delete/update operations, before image (before the change is recorded) and after image (after the change is recorded) are generated)
Through before image and after image, you can find the status before and after the data change, and use it for database recovery or transaction rollback.
You can perform insert, update, and deltet operations and observe
[Rowlog contents 0]
,[Rowlog Contents 1]