Problem solve Get help with specific problems with your technologies, process and projects.

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 last published in November 2004

Dig Deeper on Windows Operating System Management



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

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.