Created
October 20, 2014 08:23
-
-
Save richardkundl/57bba73b737abf4c8dc2 to your computer and use it in GitHub Desktop.
Azure SQL database size query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GO | |
select sum(reserved_page_count) * 8.0 / 1024 AS DbSizeInMB | |
from sys.dm_db_partition_stats | |
GO | |
select sys.objects.name as 'TableName', sum(reserved_page_count) * 8.0 / 1024 as 'Size (in MB)' | |
from sys.dm_db_partition_stats, sys.objects | |
where sys.dm_db_partition_stats.object_id = sys.objects.object_id | |
group by sys.objects.name | |
order by 'Size (in MB)' desc | |
GO | |
SELECT o.name AS ObjectName, | |
i.name AS IndexName, | |
ddips.avg_fragmentation_in_percent, | |
ddips.page_count, | |
ddips.compressed_page_count, | |
ddips.index_depth, | |
ddips.record_count | |
FROM sys.dm_db_index_physical_stats(DB_ID('{{DB-NAME}}'), | |
OBJECT_ID('{{DB-NAME}}'), DEFAULT, | |
DEFAULT, | |
'DETAILED') AS ddips | |
JOIN sys.objects AS o | |
ON ddips.object_id = o.object_id | |
JOIN sys.indexes AS i | |
ON ddips.index_id = i.index_id | |
AND ddips.object_id = i.object_id; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment