Sum of size of set of tables in Megabytes

  • I need to get a sum of the size of a certain set of tables in megabytes. I know I can use sp_spaceused, and use a cursor to loop through the tables, but the results comes back something like '2046 KB'.

    I guess I could use substring and patindex to strip off the 'KB' and then convert the varchar to a number, but if anyone else has a good way to get the total sum of bytes for a list of tables I would like to see it.

    Thanks,

    Keith

  • Use the DMV sys.dm_db_partition_stats instead, then it's much easier to tweak.

    If you want a complete solution, already built, I quite like this one:

    http://www.rmjcs.com/SQLServer/DMVs/sysdm_db_partition_stats/tabid/55/Default.aspx

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply