Skip to content

Instantly share code, notes, and snippets.

@henricavalcante
Created October 24, 2012 17:58
Show Gist options
  • Save henricavalcante/3947712 to your computer and use it in GitHub Desktop.
Save henricavalcante/3947712 to your computer and use it in GitHub Desktop.
SQL SERVER - Used disk space - Espaço usado por tabela em disco
SELECT object_name(id) AS name,
indid,
rowcnt AS rows,
reserved * 8 AS reserved_kb,
dpages * 8 AS data_kb,
(sum(used) * 8) - (dpages * 8) AS index_size_kb,
(sum(reserved) * 8) - (sum(used) * 8) AS unused_kb
FROM sysindexes
WHERE indid IN (0,1) -- cluster e não cluster
AND OBJECTPROPERTY(id, 'IsUserTable') = 1
GROUP BY id, indid, rowcnt, reserved, dpages
ORDER BY rowcnt DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment