declare aaa cursor for
select table_name from information_schema.tables WHERE TABLE_type='BASE TABLE' order by table_name
open aaa
declare @tb varchar(255)
fetch next from aaa into @tb
while @@fetch_status=0
begin
exec(' select '+''''+@tb+''''+' TBNM,(select count(*) from '+@tb+' ) cnt,ltrim(str(sum(reserved) * (select d.low from master.dbo.spt_values d where d.number = 1 and d.type = ''E'') / 1024.,15,0) +'' '' + ''KB'') '
+' +''/''+ ltrim(str(sum(used) * (select d.low from master.dbo.spt_values d where d.number = 1 and d.type = ''E'') / 1024.,15,0) +'' '' + ''KB'') used '
+' from sysindexes
where indid in (0, 1, 255)
and id = (select id from sysobjects
where id = object_id('+''''+@tb+''''+')) ')
fetch next from aaa into @tb
end
close aaa
deallocate aaa
select table_name from information_schema.tables WHERE TABLE_type='BASE TABLE' order by table_name
open aaa
declare @tb varchar(255)
fetch next from aaa into @tb
while @@fetch_status=0
begin
exec(' select '+''''+@tb+''''+' TBNM,(select count(*) from '+@tb+' ) cnt,ltrim(str(sum(reserved) * (select d.low from master.dbo.spt_values d where d.number = 1 and d.type = ''E'') / 1024.,15,0) +'' '' + ''KB'') '
+' +''/''+ ltrim(str(sum(used) * (select d.low from master.dbo.spt_values d where d.number = 1 and d.type = ''E'') / 1024.,15,0) +'' '' + ''KB'') used '
+' from sysindexes
where indid in (0, 1, 255)
and id = (select id from sysobjects
where id = object_id('+''''+@tb+''''+')) ')
fetch next from aaa into @tb
end
close aaa
deallocate aaa