MS_SQL check data-file size by using script
Data-file size check and get information for all databases on the server :-
==============================================
SELECT STATS.Volume_Mount_Point AS 'Drive',
DB_NAME(STATS.Database_ID) AS 'Database Name',
FILES.[Name] AS 'File Name',
FILES.[Size] / 128 AS 'File Size',
((STATS.Total_Bytes / 1024) / 1024)
AS 'Drive Capacity (MB)',
((STATS.Available_Bytes / 1024) / 1024)
AS 'Drive Free Space (MB)'
FROM sys.master_files FILES
CROSS APPLY
sys.dm_os_volume_stats
(FILES.database_id, FILES.file_id) STATS
==============================================
SELECT STATS.Volume_Mount_Point AS 'Drive',
DB_NAME(STATS.Database_ID) AS 'Database Name',
FILES.[Name] AS 'File Name',
FILES.[Size] / 128 AS 'File Size',
((STATS.Total_Bytes / 1024) / 1024)
AS 'Drive Capacity (MB)',
((STATS.Available_Bytes / 1024) / 1024)
AS 'Drive Free Space (MB)'
FROM sys.master_files FILES
CROSS APPLY
sys.dm_os_volume_stats
(FILES.database_id, FILES.file_id) STATS
Comments
Post a Comment