Tracking Log File Growth on SQL Server 2000

Gert Drapers, whom I consider to be a super-genius of the SQL Server world and owner of the very useful website, wrote a useful little script a few years ago that I thought I'd share.  This is a SQL query that will show who and what is causing the log of a database, in this case tempdb, to grow:

USE tempdb

SELECT Operation,
   \[Log Size\] = SUM(\[Log Record Length\])
FROM ::fn_dblog(null, null)
GROUP BY Operation, Context

This dumps the active part of the log in tempdb and provides an aggregate per operation and the context it occured in. The \[Object Name\] and \[Index Name\] columns provide info on which object, \[Server UID\], \[UID\] and \[SPID\] can provide user context when applicable.



Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.