Problem Statement:
This article describes how to display the data and log space information for a database in SQL Server by using SQL Server Management Studio or Transact-SQL.
Code Snippet:
-- Return volume stats for the drive(s) hosting database files /* This script will display files used by Database, Disk Volume, Total and Available Space on Disk, Cussrent Size of Database files */ SELECT d.name database_name, f.name logical_filename, s.volume_mount_point volume, s.total_bytes volume_size, s.available_bytes free_space, f.size current_file_size FROM sys.sysdatabases AS d JOIN sys.master_files AS f ON d.dbid = f.database_id CROSS APPLY sys.dm_os_volume_stats(f.database_id, f.file_id) AS s;