Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a way to get the accurate file size for a particular DB?

Status
Not open for further replies.

SteveMe

MIS
Aug 30, 2002
83
US
I need to be able to get the total file size of the mdf file size and the ldf file size for a particular DB and they have to be accurate. It appears that the sysaltfiles isn't accurate. Please advise.

Steve
 
If you open Enterprise Manager and do a right mouse click over the database to view the properties the size is listed. The sysaltfiles is showing the total space taken up by the database files, not the amount of data.
 
You can also try sp_helpdb.

With Great Power Comes Great Responsibility!!! [afro]

Michael
 
Or sp_spaceused @updateusage=true.

Or taking filename(s) from sysaltfiles for particular dbid then calling xp_getfiledetails... nah, don't like it.



------
[small]<this is sig>
select stuff(stuff(replicate('<P> <B> ', 14), 109, 0, '<.'), 112, 0, '/')
</this is sig>[/small]
[banghead]
 
ahhh...you could grab the filename/path from sysfiles, then run

exec xp_getfiledetails 'c:\path\to\your\database.mdb'

This will return all of the files details such as size, last access, etc...etc. If you run it in query analyzer you can see what's available to you.
 
Or you can run the following to find the sizes for all data/log files for all databases in your system:
Code:
exec master.dbo.sp_MSforeachdb 'use ? select db_name() as dbname, * from sysfiles'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top