Get Space Used by Table

    Date: 01/12/06 (SQL Server)    Keywords: no keywords

    Get the space consumed by a particular table or group of tables, including their indexes:

    select
    substring(object_name(o.id),1,40) "Table Name",
    (sum(convert(float,used)) * min(d.low) ) / 1024000.0 MBytes
    from sysindexes i, master.dbo.spt_values d, sysobjects o
    where o.id = i.id
    and indid in (0, 1, 255) and d.number = 1 and d.type = 'E'
    and object_name(o.id) like ('% %')
    group by substring(object_name(o.id),1,40)
    order by mbytes desc
    compute sum((sum(convert(float,used)) * min(d.low) ) / 1024000.0)

    Source: http://www.livejournal.com/community/sqlserver/39863.html

« Hello World and a question || Using SQL Server to... »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home