Friday 30 December 2016

Demonstrate between fn_dblog() and fn_dump_dblog()

fn_dblog()

This table-valued function (which was DBCC Log prior to SQL Server 2005) allows you to view the entries in online transaction log. This procedure accepts 2 parameters, the start and the end LSN. To see all available entries NULL can be passed for both parameters, and all the entries in the active portion of the online log will be displayed.
  SELECT * FROM fn_dblog(NULL,NULL)

fn_dump_dblog()

This function reads both the online log and log backups and accepts 68 parameters. All the parameters need to be specified in order to execute the statement.
SELECT * FROM fn_dump_dblog
(NULL, NULL, N'DISK', 1,
N'D:\Backup\New folder\ReadingDBLog_201503022236.trn', DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT,
DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT,
DEFAULT, DEFAULT,DEFAULT, DEFAULT, DEFAULT, DEFAULT,
DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT,
DEFAULT, DEFAULT, DEFAULT, DEFAULT,DEFAULT, DEFAULT,
DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT,
DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT,
DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT,
DEFAULT, DEFAULT,DEFAULT, DEFAULT, DEFAULT, DEFAULT,
DEFAULT, DEFAULT, DEFAULT)WHERE Operation = 'LOP_DELETE_ROWS' GO


ParameterDescription
@startThe start LSN
@endThe end LSN
@devtypeThis is the backup device type. The default value is DISK. Other valid values are NULL(DISK) | DISK | TAPE | VIRTUAL_DEVICE
@seqnumThis indicates which backup to read from a backup device if there is more than one backup in a backup file. The default value is 1.
@fname1This parameter accepts the path to the backupfile.
@fname2 to @fname64These parameters are used to specify additional backup files, if the media set has multiple media families.

No comments:

Post a Comment