SQLAspire

Monday, September 16, 2013

Simple SQL query to find the size of tables in a database

SELECT DISTINCT
st.name
, SUM (total_pages)*8.0/1024.0 AS [Size in MB]
FROM sys.partitions sp
INNER JOIN sys.tables st
ON sp.object_id = st.object_id
INNER JOIN sys.allocation_units sa
ON sp.partition_id = sa.container_id
GROUP BY st.name

Posted by SQLAspire at 9:13 PM No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Newer Posts Older Posts Home
Subscribe to: Posts (Atom)

Blog Archive

  • ►  2023 (3)
    • ►  February (1)
    • ►  January (2)
  • ►  2022 (6)
    • ►  December (6)
  • ►  2015 (4)
    • ►  August (1)
    • ►  March (2)
    • ►  February (1)
  • ►  2014 (4)
    • ►  December (1)
    • ►  July (1)
    • ►  May (1)
    • ►  April (1)
  • ▼  2013 (9)
    • ►  December (1)
    • ►  November (1)
    • ►  October (3)
    • ▼  September (1)
      • Simple SQL query to find the size of tables in a d...
    • ►  May (1)
    • ►  March (1)
    • ►  January (1)
  • ►  2012 (7)
    • ►  December (1)
    • ►  October (1)
    • ►  September (1)
    • ►  August (3)
    • ►  July (1)

About Me

SQLAspire
View my complete profile
Awesome Inc. theme. Powered by Blogger.