Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 252
  • Last Modified:

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
0
Carlos_Felipe
Asked:
Carlos_Felipe
1 Solution
 
momi_sabagCommented:
you can use sp_spaceused
0
 
chapmandewCommented:

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
 
Carlos_FelipeAuthor Commented:
It works!

Thanks!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now