Below query will give you list of tables with space usage analysis
DECLARE @TblName TABLE (Tname NATIONAL CHARACTER VARYING(255))
DECLARE @SPACEDATA TABLE( Tname NATIONAL CHARACTER VARYING(255), Trows int, Treserved NVARCHAR(25), TDatasize VARCHAR (25), Tindex_size VARCHAR(10), Tunused VARCHAR(10))
DECLARE @Tname nvarchar(255)
INSERT INTO @TblName
SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE ='BASE TABLE'
DECLARE CsrTblName CURSOR FOR SELECT Tname FROM @TblName
OPEN CsrTblName
FETCH CsrTblName INTO @Tname
WHILE @@FETCH_STATUS =0
BEGIN
INSERT INTO @SPACEDATA
exec sp_spaceused @Tname
FETCH CsrTblName INTO @Tname
END
--SELECT * FROM @SPACEDATA ORDER BY Tdatasize DESC
SELECT
Tname
,Trows
,Treserved
,TDatasize
,Tindex_size
,Tunused
FROM @SPACEDATA Order by Treserved DESC
CLOSE CsrTblName
DEALLOCATE CsrTblName
DECLARE @TblName TABLE (Tname NATIONAL CHARACTER VARYING(255))
DECLARE @SPACEDATA TABLE( Tname NATIONAL CHARACTER VARYING(255), Trows int, Treserved NVARCHAR(25), TDatasize VARCHAR (25), Tindex_size VARCHAR(10), Tunused VARCHAR(10))
DECLARE @Tname nvarchar(255)
INSERT INTO @TblName
SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE ='BASE TABLE'
DECLARE CsrTblName CURSOR FOR SELECT Tname FROM @TblName
OPEN CsrTblName
FETCH CsrTblName INTO @Tname
WHILE @@FETCH_STATUS =0
BEGIN
INSERT INTO @SPACEDATA
exec sp_spaceused @Tname
FETCH CsrTblName INTO @Tname
END
--SELECT * FROM @SPACEDATA ORDER BY Tdatasize DESC
SELECT
Tname
,Trows
,Treserved
,TDatasize
,Tindex_size
,Tunused
FROM @SPACEDATA Order by Treserved DESC
CLOSE CsrTblName
DEALLOCATE CsrTblName