Get a list of all tables from a database and their respective size in MB

How to list all tables of a SQL Server database and their respective size in MB?

Thanks,

Felipe
Carlos_FelipeAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
chapmandewConnect With a Mentor Commented:

create table #t(tablename nvarchar(255), rows int, reserved nvarchar(255), data nvarchar(255), index_size nvarchar(255), unused nvarchar(255))

insert into #t
exec sp_msforeachtable 'exec sp_spaceused [?]'

select * from #t
order by rows desc
0
 
momi_sabagCommented:
you can use sp_spaceused
0
 
Carlos_FelipeAuthor Commented:
It works!

Thanks!
0
All Courses

From novice to tech pro — start learning today.