Two quickest ways to find file information of a given database

This post was written by namwar on January 2, 2009
Posted Under: How-To, Query, SQL Server 2005, SQL Server 2008, System stored procedures, TSQL

If you want to check the name of the files and their respective sizes for the given database then following are two quick tsql scripts:

1. Use sp_helpfile

This stored procedure returns the file information for the selected database e.g.

USE AdventureWorks;

GO

EXEC sp_helpfile;

GO

It will return the resultset similar to following

sp_hellpfile result set
sp_hellpfile result set

By default, this view returns a column called size but this is actually the size in 8KB pages therefore, to get the exact size in KB, as returned by sp_helpfile, multiply it by 8 as mentioned in above query.

Reader Comments

i can see the first way listed in the blog. what is the second way?

#1 
Written By tjaybelt on January 12th, 2009 @ 7:05 pm

Add a Comment

required, use real name
required, will not be published
optional, your blog address