How to retrieve SQL Server database disk space in use

I am trying to retrieve the current amount of disk space being used by our SQL Server databases. I'd like to enter the results into a table where I can use the fields to populate a report. How can I find this information?

    Requires Free Membership to View

The current size of the data files can be found within the SQL Server. You can use the sysaltfiles table (system view in SQL Server 2005 and up) to see how large each file is.

SELECT name, filename, (size*8)/1024
FROM sysaltfiles.

This was first published in March 2008

Join the conversationComment

Share
Comments

    Results

    Contribute to the conversation

    All fields are required. Comments will appear at the bottom of the article.