Space Used By Table

  • Comments posted to this topic are about the item Space Used By Table

  • Another way to do it. . .

    CREATE TABLE #temp

    (

    [name] nvarchar(128),

    [rows] char(11),

    [reserved] varchar(18),

    [data] varchar(18),

    [index_size] varchar(18),

    [unused] varchar(18)

    )

    INSERT INTO #temp

    EXEC sp_MSforeachtable @command1="EXEC sp_spaceused '?' "

    SELECT

    [name] AS TableName,

    CAST([rows] AS int) AS NumOfRows,

    CAST(REPLACE([reserved],' KB','') AS int) AS [TotalKB]

    FROM

    #temp

    ORDER BY 3 DESC

    SELECT SUM(CAST(REPLACE([reserved],' KB','') AS int)) AS TotalKB_data FROM #temp

    DROP TABLE #temp

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply