Skip to content

Instantly share code, notes, and snippets.

@hishaamn
Created September 21, 2025 09:14
Show Gist options
  • Select an option

  • Save hishaamn/edacf2492f04dd699b701e10550582e5 to your computer and use it in GitHub Desktop.

Select an option

Save hishaamn/edacf2492f04dd699b701e10550582e5 to your computer and use it in GitHub Desktop.
EXEC sp_MSforeachdb '
IF ''?'' LIKE ''%Xdb.Collection.Shard%''
BEGIN
USE [?];
SELECT
DB_NAME() AS DatabaseName,
name AS FileName,
type_desc AS FileType,
size/128 AS CurrentSizeMB,
size/128.0 - CAST(FILEPROPERTY(name, ''SpaceUsed'') AS INT)/128.0 AS FreeSpaceMB,
growth/128 AS GrowthSizeMB,
CASE is_percent_growth
WHEN 1 THEN CAST(growth AS VARCHAR(10)) + ''%''
ELSE CAST(growth/128 AS VARCHAR(10)) + '' MB'' END AS GrowthSetting
FROM sys.database_files;
END
';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment