Table Sizes and Indexes such as Task Pad View

Table Sizes and Indexes such as Task Pad View

This tip was submitted to the tip exchange by Jennifer Perez. Please let other users know how...

useful it is by rating it below.

Table Sizes and Indexes such as Task Pad View in SQL Server 2000 display valuable information regarding database size/indexes, but do not allow you to easily move that information from Enterprise Manager into something else. The below code is the same code that Enterprise Manager uses to retrieve its data, and is very helpful in determining database bottlenecks or when to federate.

--Start Script --
select sysTableTemp.UsersName + '.' + sysTableTemp.ObjectsName 
as CompleteName,  sysTableTemp.IndexName, sysTableTemp.rows,  
case when sysTableTemp.indid  =  1 Then 1
  Else 0
 End as IsClusteredIndex,
  when sysTableTemp.indid > 1 and sysTableTemp.indid <> 255 
   Then pageTableTemp.PageSize * sysTableTemp.NonClusteredDataUsed end) as 
NonClusteredDataUsed, (pageTableTemp.PageSize * (isnull(sysTableTemp.AllData,
 0))) As DataSizeUsed,
  ( case 
   when sysTableTemp.indid  =  1 
    Then pageTableTemp.PageSize * 
     (isnull(sysTableTemp.IndexSizeUsed, 0)- isnull(sysTableTemp.DataSizeUsed,
 0)) end) AS ClustedDataUsed from  ( select  v.low / 1024 as PageSize 
 from    master..spt_values v  
 where   v.number=1 and v.type=N'E' ) as pageTableTemp, 
  select  sysindexes.indid, as IndexName, as
ObjectsName, as UsersName, sysindexes.used as 
NonClusteredDataUsed, tempTable.DataSizeUsed, tempTable.IndexSizeUsed, 
   tempTable.rows, tempTable.AllData 
  from   sysindexes, sysobjects, sysusers, ( 
   select  id, 
    sum(case indid 
     when 0   then sysindexes.dpages 
     when 1   then sysindexes.dpages 
     when 255 then isnull(sysindexes.used, 0) end) as DataSizeUsed, 
    sum(case indid  
     when 0 then isnull(sysindexes.used, 0) 
     when 1 then isnull(sysindexes.used, 0) 
     when 255 then isnull(sysindexes.used, 0) end) as IndexSizeUsed, 
    sum(case indid 
     when 0 then convert(int, rows) 
     when 1 then convert(int, rows) end) as rows, 
     when indid <= 0 then sysindexes.dpages + isnull(sysindexes.used, 0)     
     else isnull(sysindexes.used, 0) end) as AllData 
   from   sysindexes group by ) as tempTable 
where =
 and sysusers.uid = sysobjects.uid
 and =
 and not like '#%'  
(, N'IsSystemTable') = 0 ) as sysTableTemp order by CompleteName, 
IsClusteredIndex DESC 
--End Script--

This was first published in November 2004

Dig Deeper on Windows Operating System Management



Find more PRO+ content and other member only offers, here.



Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:









  • VDI assessment guide

    Wait! Don't implement VDI technology until you know your goals and needs. A VDI assessment should consider the benefits of a VDI ...

  • Guide to calculating ROI from VDI

    Calculating ROI from VDI requires a solid VDI cost analysis. Consider ROI calculation models, storage costs and more to determine...

  • Keep the cost of VDI storage under control

    Layering, persona management tools and flash arrays help keep virtual desktop users happy and VDI storage costs down.