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

    By submitting your registration information to SearchSQLServer.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchSQLServer.com is governed by our Terms of Use. You may contact us at [email protected].

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.