Solved

Querying log size

Posted on 2009-04-01
4
283 Views
Last Modified: 2012-05-06
I'm about to write a script to tell me the log size before/after some events.
So I was looking into the sys.xxx to see where I could find the one for log size and came up with
select * from sys.database_files
This tells me the log is 3163192 (31GB) yet when I double check this with windows explorer the log (file size) is 25GB.
I have right clicked and ensured the size on disk is also 25GB.
When I look at the disk space usage reports it says the log is 24.7GB and 99.3% unused.

Why the huge size difference between what windows explorer tells me and what database_files says.
0
Comment
Question by:QPR
4 Comments
 
LVL 37

Expert Comment

by:momi_sabag
Comment Utility
which column of sys.database_files did you check in order to determine the size?
0
 
LVL 19

Accepted Solution

by:
Rimvis earned 250 total points
Comment Utility
sys.database_files stores size in pages. Page size is 8KB

To get size in GB use this:
select (siZe  * 8)/(1024.0*1024.0)AS SizeInGB, *    from sys.database_files
0
 
LVL 8

Assisted Solution

by:vinurajr
vinurajr earned 250 total points
Comment Utility
sp_helpdb DBName will tells the exact file size or the sysdatabases
you Interpreted wrongly.... The size in the sys.database_files is nothing but Current size of the file, in 8-KB pages.


select (3163192*8)/(1024.0*1024.0)
0
 
LVL 29

Author Comment

by:QPR
Comment Utility
ahhh I see I was using select size/1000 and assumed I was dealing with actual file size.
Points split:
Rimvis for pointing out my problem and vinurarj for reminding me about sp_helpdb which I will now use
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now