by

Como obter o espaço em disco ocupado por cada tabela do Banco de Dados

Como obter o espaço em disco ocupado por cada tabela do Banco de Dados
O código abaixo retorno espaço em disco ocupado por cada tabela do banco de dados em em execução.
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/4293546/Como-obter-o-espa-o-em-disco-ocupado-por?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
SELECT t.NAME AS Entidade, p.rows AS Registros, SUM(a.total_pages) * 8 AS EspacoTotalKB, SUM(a.used_pages) * 8 AS EspacoUsadoKB, (SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS EspacoNaoUsadoKB FROM sys.tables t INNER JOIN sys.indexes i ON t.OBJECT_ID = i.object_id INNER JOIN sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id INNER JOIN sys.allocation_units a ON p.partition_id = a.container_id LEFT OUTER JOIN sys.schemas s ON t.schema_id = s.schema_id WHERE t.NAME NOT LIKE 'dt%' AND t.is_ms_shipped = 0 AND i.OBJECT_ID > 25 AND P.rows > 0 -- and t.NAME like 'PEC_pre%' GROUP BY t.Name, s.Name, p.Rows ORDER BY EspacoTotalKB DESC
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus