If you want to get the listed report of all monitoring tables like shown at the picture, please use SQL code shown below:
DECLARE @TableName VARCHAR(100)
DECLARE tableCursor CURSOR
FOR
select [name]
from dbo.sysobjects
where OBJECTPROPERTY(id, N'IsUserTable') = 1
FOR READ ONLY
CREATE TABLE #TempTable
(
tableName varchar(100),
numberofRows varchar(100),
reservedSize varchar(50),
dataSize varchar(50),
indexSize varchar(50),
unusedSize varchar(50)
)
OPEN tableCursor
FETCH NEXT FROM tableCursor INTO @TableName
WHILE (@@Fetch_Status >= 0)
BEGIN
INSERT #TempTable
EXEC sp_spaceused @TableName
FETCH NEXT FROM tableCursor INTO @TableName
END
CLOSE tableCursor
DEALLOCATE tableCursor
SELECT *
FROM #TempTable
DROP TABLE #TempTable
GO
Posted
Sep 17 2010, 09:13 AM
by
Damir Dobric