If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Microsoft SQL Server > Finding out physical size of table

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-26-12, 09:22
Breako Breako is offline
Registered User
 
Join Date: Jan 2006
Posts: 119
Finding out physical size of table

Hi,
Just wondering say if I have a table of 1,000,000 rows how I do find out what size this table is on disk?

And how do I find out the size of all tables on disc?

Thanks
Reply With Quote
  #2 (permalink)  
Old 01-26-12, 09:32
MCrowley MCrowley is offline
Wage drone 24601
 
Join Date: Jan 2003
Location: Massachusetts
Posts: 4,899
this should get you started:
Code:
select object_name(p.object_id) as "Table", 
	p.index_id, 
	f.name, 
	sum(total_pages)/128 as "Size in MB",
	convert(varchar(10), getdate(), 101), 
	count(*) as partitions
from sys.partitions p join
	sys.allocation_units a on p.partition_id = a.container_id join
	sys.filegroups f on a.data_space_id = f.data_space_id
group by p.object_id, p.index_id, f.name
order by sum(total_pages)/128 desc
Reply With Quote
  #3 (permalink)  
Old 01-26-12, 11:40
Breako Breako is offline
Registered User
 
Join Date: Jan 2006
Posts: 119
Quote:
Originally Posted by MCrowley View Post
this should get you started:
Code:
select object_name(p.object_id) as "Table", 
	p.index_id, 
	f.name, 
	sum(total_pages)/128 as "Size in MB",
	convert(varchar(10), getdate(), 101), 
	count(*) as partitions
from sys.partitions p join
	sys.allocation_units a on p.partition_id = a.container_id join
	sys.filegroups f on a.data_space_id = f.data_space_id
group by p.object_id, p.index_id, f.name
order by sum(total_pages)/128 desc
Thanks another good one is..

EXEC sp_spaceused 'Tablename'

Just to get info on a specific table.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On