Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Space usage by table on each file

Author  Topic 

rubs_65
Posting Yak Master

144 Posts

Posted - 2006-08-21 : 18:20:20
Hi,

We have 2 datafiles of about 100GB each and a particular table using about 45GB. Is there a way that we can check how much pages/space the table is using on each file.

Thanks
--Harvinder

eyechart
Master Smack Fu Yak Hacker

3575 Posts

Posted - 2006-08-21 : 18:25:29
check out the sp_spaceused system stored procedure.



-ec
Go to Top of Page

rubs_65
Posting Yak Master

144 Posts

Posted - 2006-08-21 : 18:48:20
where sp_spaceused show for each file?
Go to Top of Page

ravilobo
Master Smack Fu Yak Hacker

1184 Posts

Posted - 2006-08-22 : 02:44:15
No. I think it works on an object. Check BOL.

------------------------
I think, therefore I am - Rene Descartes
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2006-08-22 : 19:28:35
This should help:

create table #a(file_id tinyint not null, page_id int not null, pg_alloc tinyint not null, ext_size tinyint not null, obj_id int not null, index_id tinyint not null, pfs_bytes binary(8) not null)
insert into #a exec('dbcc extentinfo(''myDatabase'',''myTable'')')
select file_id, count(*) extents, sum(pg_alloc) pagesused, sum(pg_alloc)*8192 bytesused from #a group by file_id
drop table #a


The byte count is approximate, and the page counts could be off too, but it will at least get you started. This will include non-clustered index pages too, but you can use:

select file_id, count(*) extents, sum(pg_alloc) pagesused, sum(pg_alloc)*8192 bytesused from #a where index_id<2 group by file_id

To filter them out. Google for "dbcc extentinfo" for more information. Also try experimenting with a test table to validate the results.

I'll leave it to you to add sysfiles data to get the actual filenames in the query results.
Go to Top of Page
   

- Advertisement -