Listas tabelas, linhas e tamanho em disco.
declare @vname sysname
declare @tmpTamTabela table (
name sysname null
, rows int null
, reserved varchar(25) null
, data varchar(25) null
, index_size varchar(25) null
, unused varchar(25) null )
declare cp1 cursor local fast_forward read_only for
select name
from sysobjects
where type = 'U'
order by name
open cp1
while 1 = 1
begin
fetch next from cp1 into @vname
if @@fetch_status 0 break
insert into @tmpTamTabela (name, rows, reserved
, data, index_size, unused)
exec sp_spaceused @vname
end
close cp1
deallocate cp1
select name as 'Nome'
, rows as 'Linhas'
, convert(int, replace(reserved, ' KB',''))/1024 as 'Tamanho total MB'
, convert(int, replace(data, ' KB',''))as 'Dados KB'
, convert(int, replace(index_size, ' KB',''))as 'Index KB'
, convert(int, replace(unused, ' KB',''))as 'Não utilizado KB'
from @tmpTamTabela
order by convert(int, replace(reserved, ' KB','')) desc
SQL