Query a MSSQL database for table sizes

We use Microsoft SQL 2005 for our mission critical and web databases. In one instance, we're able to use SQL Express just fine, but lately I had been keeping an eye on a DB that was approaching the 4GB limit imposed on SQL Express. I had a Google for queries to list the table sizes (it's simple enough to find out the size of a single table in Management Studio, but querying is clearly simpler/faster). I found exactly what I was looking for, thanks to Scott Moss. Paste this below, replacing OnePoint with your DB name. Everything else is fine as is.

-- 12/16/2007 -- Any DB will show the table size in MegaBytes -- worked with a SQL Guru at M$ for a few hours last week, here are some fruits of mostly his labor Use OnePoint Go

select object_name(id) [Table Name], [Table Size] = convert (varchar, dpages * 8 / 1024) + 'MB'

from sysindexes where indid in (0,1) order by dpages desc

-- Have A great Week!

Thank you Scott Moss!