|
Need to look at all the tables and their sizes for a database. Is there a DMV that I can use to accomplish this task? thanks!
(comments are locked)
|
|
Use reports. Right click a database, choose reports, then 'Disk usage by Table'. This will give you a report that details for each table, the number of rows and how much disk space is taken up by the table (separated out as data + indexes). If you need to add any more info, or tweak it slightly, capture the SQL that the report uses to generate the data, and build your own table reporting query. For some reason, I always forget about those reports!! ;-) Excellent suggestion. Nice & easy.
Apr 30 '12 at 02:50 PM
JohnM
John and Kev thanks so much for your help. By the way, Kev how do i capture the SQL for the report?
Apr 30 '12 at 02:56 PM
clayp56
Use Profiler or server-side trace. To be honest, it's going to give you something like @JohnM suggested anyway.
Apr 30 '12 at 02:58 PM
Kev Riley ♦♦
(comments are locked)
|
|
You can do something like this: Modified to show the size of the used pages. Borrowed from here: http://www.dbforums.com/microsoft-sql-server/1003535-query-showing-tablesize-mb.html This should work in SQL 2005 & SQL 2008. Hope this helps!!
(comments are locked)
|
|
Yes, there is a dmv. You can use dm_db_partition_stats (details) to get this information:
(comments are locked)
|

