• Way too complicated of a solution for what is needed here. Here the information is in one SELECT statement from three system tables that gives you all the same basic information that sp_spaceused does and without any looping, using TEMP tables, or cursors, and orders then by the largest rows first to boot!. KISS. 😀

    SELECT

    sysusers.name as TABLE_USER,

    sysobjects.name as TABLE_NAME,

    sum(sysindexes.rowcnt) as ROWS,

    sum(case when sysindexes.indid in (0, 1, 255) then convert(dec(15),reserved*8)else 0 end) as RESERVED_Kb,

    sum(case when sysindexes.indid < 2 THEN convert(dec(15),dpages*8) ELSE 0 END) +

    sum(case when sysindexes.indid = 255 THEN convert(dec(15),used*8) ELSE 0 END) AS DATA_Kb,

    (sum(case when sysindexes.indid in (0, 1, 255) then convert(dec(15),used*8) ELSE 0 END) -

    sum(case when sysindexes.indid < 2 THEN convert(dec(15),dpages*8) ELSE 0 END) -

    sum(case when sysindexes.indid = 255 THEN convert(dec(15),used*8) ELSE 0 END)) AS INDEX_SIZE_Kb,

    sum(case when sysindexes.indid in (0, 1, 255) then convert(dec(15),(reserved - used)*8) else 0 end) AS UNUSED_Kb

    FROM sysobjects (NOLOCK) INNER JOIN

    sysindexes (NOLOCK) ON sysobjects.id = sysindexes.id

    INNER JOIN sysusers (NOLOCK) ON sysobjects.uid = sysusers.uid

    WHERE (sysobjects.type = 'U')

    group by sysusers.name, sysobjects.name

    ORDER BY ROWS DESC

    GO

    "Technology is a weird thing. It brings you great gifts with one hand, and it stabs you in the back with the other. ...:-D"