How to Find the Space Used in Your Data Files

I recently had to resize a data file on of my production SQL Server databases and needed to know an appropriate size to resize it to. So, I created this simple script that queries sys.database_files and brings back the File ID, File Location, File Name, Original Size, Space Used and Space Left.

[snippet id=”22″]

Here is a sample result of the output:

SCRIPT-Space-Used-vs-Space-Left-Datafiles

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.