Peter Larsson Blog

Patron Saint of Lost Yaks

Reading the transaction log

SELECT        *
FROM          ::fn_dblog(DEFAULT, DEFAULT) AS l
INNER JOIN    sysobjects AS so ON so.name = l.[transaction name]

SELECT        so.name AS ObjectName,
              so.type AS ObjectType,
              MAX(CAST(l.[Begin Time] AS DATETIME)) AS LogTime
FROM          ::fn_dblog(DEFAULT, DEFAULT) l
inner join    sysobjects so on so.name = l.[transaction name]
--where              so.type = 'u'
GROUP BY      so.name,
              so.type
ORDER BY      so.name,
              so.type

Legacy Comments


Michael Swart
2008-11-13
re: Reading the transaction log
That's a really useful script for looking at the transaction log.

I haven't needed to look at the transaction log ever since my last project that used replication. Can you think of any other situations where this information will help solve problems. It would make a good post.

Cheers