Skip to main content

Command Palette

Search for a command to run...

Get size of all tables in database

Updated
1 min read
SELECT 
  o.name AS ObjectName, 
  SUM(reserved_page_count) * 8.0 / 1024 AS SizeinMB 
FROM 
  sys.dm_db_partition_stats AS ps 
  INNER JOIN sys.sysobjects AS o ON ps.object_id = o.id 
GROUP BY 
  o.name 
ORDER BY 
  SizeinMB DESC;

More from this blog

Fix, Build, Automate

17 posts

Straightforward solutions for modern tech problems