The SQL Server sp_spaceused stored procedure is useful for finding out a database size, unallocated space, etc. However (as far as I can tell), it does not report that information for the transaction log (and looking at database properties within SQL Server Management Studio also does not provide that information for transaction logs).

While I can easily find the physical space used by a transaction log by looking at the .ldf file, how can I find out how much of the log file is used and how much is unused?

link|improve this question

feedback

4 Answers

up vote 3 down vote accepted

Found the answer just after I submitted the question :)

It looks like dbcc sqlperf(logspace) and dbcc loginfo are my friend.

http://www.mssqltips.com/tip.asp?tip=1225

link|improve this answer
This is definitely the best way, and would have been my answer. – Paul Randal Jun 24 '09 at 14:34
feedback

Another way - perform in MS SQL Management Studio the following command:

  • Right click on the database
  • Tasks
  • Shrink
  • Files

and select File Type = Log you will not only see the file size and % of available free space.

link|improve this answer
feedback

For a more GUI approach SQL Management studio can create a disk space (amongst others) report for a database (right click on the database node in the object explorer, select reports).

This report will also show information on recent file resizes.

link|improve this answer
feedback

Another way - fire up perfmon and check out the following counters:

  • SQLServer:Databases Log File(s) Size(KB)
  • SQLServer:Databases Log File(s) Used Size(KB)
  • SQLServer:Percent Log Used

These values update in real-time.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.